From 8e0b2c7bde971a9acc35b598ff7d290a87bc7197 Mon Sep 17 00:00:00 2001 From: L480 Date: Fri, 8 Mar 2024 10:27:14 +0100 Subject: [PATCH] Fixed response --- workers/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/workers/index.js b/workers/index.js index ecc08da..6de1479 100644 --- a/workers/index.js +++ b/workers/index.js @@ -69,10 +69,12 @@ export default { } // JSON response with cache and CORS - const response = new Response(JSON.stringify(allTonies)); - response.headers.set('Content-Type', 'application/json'); - response.headers.set("Cache-Control", "max-age=" + cacheTtl); - response.headers.set("Access-Control-Allow-Origin", env.CORS_ORIGINS); - return response; + return Response.json(allTonies, { + headers: { + 'Cache-Control': 'max-age=' + cacheTtl, + 'Access-Control-Allow-Origin': env.CORS_ORIGINS, + 'Access-Control-Allow-Methods': 'GET', + } + }); }, };