From 90fb11324804b0466a6282d103a6444a00c68a4b Mon Sep 17 00:00:00 2001 From: imbytecat Date: Wed, 12 Apr 2023 01:58:09 +0800 Subject: [PATCH] fix cors --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 44648e2..5210d91 100644 --- a/index.js +++ b/index.js @@ -46,7 +46,12 @@ http statusCode = 404; } - response.writeHead(statusCode, { "Content-Type": "application/json" }); + response.writeHead(statusCode, { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "OPTIONS, POST, GET", + "Access-Control-Max-Age": 2592000, // 30 days + "Content-Type": "application/json", + }); response.end(JSON.stringify(responseBody)); }) .listen(8888);