diff options
Diffstat (limited to 'server')
-rwxr-xr-x | server/index.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/index.js b/server/index.js index 64b4138..65ae6bb 100755 --- a/server/index.js +++ b/server/index.js @@ -144,12 +144,26 @@ function notImplemented(req, res) })); } +function optionsHeader(req, res) +{ + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Request-Method', '*'); + res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET'); + res.setHeader('Access-Control-Allow-Headers', '*'); + if ( req.method === 'OPTIONS' ) + { + res.writeHead(200); + res.end(); + } +} + function processMethod(req, res) { switch(req.method) { case 'GET': getRoutes(req, res); break; case 'POST': postRoutes(req, res); break; + case 'OPTIONS': optionsHeader(req, res); break; default: notImplemented(req, res); } } |