diff --git a/index.js b/index.js index 58faf1e..654c971 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ var fs = require('fs'); var sqlite3 = require('./sqlite3-promises'); var express = require('express'); +var cors = require('cors'); const POLLING_TIMEOUT = 60000/*ms*/; @@ -428,6 +429,8 @@ async function postGameHandler(req, res, next) { const app = express(); +app.use(cors()); + app.get('/pacosako/api/games/poll/:afterTime', catchExceptionsJson(getGameListHandler)); app.get('/pacosako/api/games', catchExceptionsJson(getGameListHandler)); diff --git a/package-lock.json b/package-lock.json index 5a8686c..bd43f66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -210,6 +210,15 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", diff --git a/package.json b/package.json index 22c97f2..a7bd511 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "dependencies": { + "cors": "^2.8.5", "express": "^4.17.1", "sqlite3": "^4.1.1" },