aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-12-05 19:56:48 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-12-05 19:56:48 +0200
commit4b6b04189a8483415da9b87602f184573197dcb6 (patch)
tree5010d94059866c2102b51e9c857b2341bcec19aa /server
parenta5040e1de1a6fdfa1dbd8f7164abda9900d8c43e (diff)
downloadarching-kaos-radio-4b6b04189a8483415da9b87602f184573197dcb6.tar.gz
arching-kaos-radio-4b6b04189a8483415da9b87602f184573197dcb6.tar.bz2
arching-kaos-radio-4b6b04189a8483415da9b87602f184573197dcb6.zip
Diffstat (limited to 'server')
-rwxr-xr-xserver/index.js14
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);
}
}