diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-12-05 19:56:48 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-12-05 19:56:48 +0200 |
commit | 4b6b04189a8483415da9b87602f184573197dcb6 (patch) | |
tree | 5010d94059866c2102b51e9c857b2341bcec19aa /server | |
parent | a5040e1de1a6fdfa1dbd8f7164abda9900d8c43e (diff) | |
download | arching-kaos-radio-master.tar.gz arching-kaos-radio-master.tar.bz2 arching-kaos-radio-master.zip |
CORS considerationHEADorigin/masterorigin/HEADmaster
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); } } |