From 47f4feea6abea824b1cb91e198e0f15cf81c0e7f Mon Sep 17 00:00:00 2001 From: andreagerino Date: Sun, 8 May 2016 18:22:21 +0200 Subject: [PATCH] Enabling CORS --- app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index e80d81c..c111385 100644 --- a/app.js +++ b/app.js @@ -14,10 +14,11 @@ app.use(bodyParser.json()); //enable CORS app.use(function(req, res, next) { - if(req.method=="OPTIONS"){ + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); + res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); - res.header("Access-Control-Allow-Origin", "*"); - res.header("Access-Control-Allow-Methods", "GET"); + if(req.method=="OPTIONS"){ res.sendStatus(204); -- 2.18.1