diff --git a/src/app.js b/src/app.js index 6154344..05a68fc 100644 --- a/src/app.js +++ b/src/app.js @@ -3,10 +3,23 @@ const logger = require('morgan') const bodyParser = require('body-parser') const app = express(); + app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); +app.options("/*", function(req, res, next){ + res.header('Access-Control-Allow-Origin', 'http://localhost:8080'); + res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); + res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With'); + res.send(200); +}); + +app.all('/*', function(req, res, next) { + res.header('Access-Control-Allow-Origin', 'http://localhost:8080') + next(); +}) + require('./routes')(app); app.get('*', (req, res) => res.status(200).send({