diff --git a/packages/server/packages/play-node-go/server/package-lock.json b/packages/server/packages/play-node-go/server/package-lock.json index 7028fad..a3f637d 100644 --- a/packages/server/packages/play-node-go/server/package-lock.json +++ b/packages/server/packages/play-node-go/server/package-lock.json @@ -229,6 +229,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" + } + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -579,6 +588,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, "object-component": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", diff --git a/packages/server/packages/play-node-go/server/package.json b/packages/server/packages/play-node-go/server/package.json index 2f4df81..dce4107 100644 --- a/packages/server/packages/play-node-go/server/package.json +++ b/packages/server/packages/play-node-go/server/package.json @@ -9,6 +9,7 @@ "chai": "^4.2.0", "chai-http": "^4.3.0", "cookie-parser": "~1.4.4", + "cors": "^2.8.5", "debug": "~2.6.9", "express": "~4.16.1", "http-errors": "~1.6.3", diff --git a/packages/server/packages/play-node-go/server/server.js b/packages/server/packages/play-node-go/server/server.js index 662bcc9..32924a7 100644 --- a/packages/server/packages/play-node-go/server/server.js +++ b/packages/server/packages/play-node-go/server/server.js @@ -1,17 +1,22 @@ -var createError = require('http-errors'); -var express = require('express'); -var path = require('path'); -var cookieParser = require('cookie-parser'); -var logger = require('morgan'); +const createError = require('http-errors'); +const express = require('express'); -var indexRouter = require('./routes/index'); -var usersRouter = require('./routes/users'); +const cors = require('cors'); +const path = require('path'); +const cookieParser = require('cookie-parser'); +const logger = require('morgan'); -var app = express(); +const indexRouter = require('./routes/index'); +const usersRouter = require('./routes/users'); -// view engine setup -app.set('views', path.join(__dirname, 'views')); -app.set('view engine', 'jade'); +const app = express(); + +const corsOptions = { + origin: '*' +} + +app.options('*', cors(corsOptions)); +app.use('*', cors(corsOptions)); app.use(logger('dev')); app.use(express.json()); @@ -35,7 +40,7 @@ app.use(function(err, req, res, next) { // render the error page res.status(err.status || 500); - res.render('error'); + res.send('error'); }); module.exports = app;