From 9a46f8c72e45795a341013a52fc93865f394522f Mon Sep 17 00:00:00 2001 From: andreagerino Date: Sun, 8 May 2016 17:46:13 +0200 Subject: [PATCH] Enabling CORS --- app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app.js b/app.js index b8dfbd6..e80d81c 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,24 @@ var app = express(); app.use(logger('dev')); 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-Methods", "GET"); + + res.sendStatus(204); + + }else{ + + next(); + + } + +}); + app.use('/icarus/str', storage); app.use('/icarus/svc', services); -- 2.18.1