From 380e701634029e9c4fe59b4dd1d800b86d5b2bdc Mon Sep 17 00:00:00 2001 From: Nishant Jain Date: Thu, 8 Mar 2018 12:08:41 +0530 Subject: [PATCH] Enabled CORS --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index f9032c6..2110ceb 100644 --- a/app.js +++ b/app.js @@ -8,6 +8,12 @@ mongoose.connect(config.mongodb.mongodbUrl); const app = express(); +app.use((req, res, next) => { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + next(); +}); + app.use('/ping', (_, res) => { res.send('pong'); });