From 588db18cda1d686a741ef0f45b27c72056ca98b9 Mon Sep 17 00:00:00 2001 From: Carlgo11 Date: Mon, 4 Nov 2024 03:00:31 +0100 Subject: [PATCH] Fix redirect function --- functions/redirect.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/redirect.js b/functions/redirect.js index d8f0b6b..1935501 100644 --- a/functions/redirect.js +++ b/functions/redirect.js @@ -8,7 +8,6 @@ export async function onRequestGet({ request }) { const country = request.cf?.country?.toLowerCase(); const res = await fetch(`${api}${country}/categories.json`, { method: 'HEAD', - cache: 'force-cache', cf: { cacheTtlByStatus: { "200": 60 * 60 * 24 * 14, // Cache request 2 weeks @@ -17,7 +16,7 @@ export async function onRequestGet({ request }) { } }); - let uri = res.status !== 200 ? `${base}${country}/` : `${base}/int/` + let uri = res.status === 200 ? `${base}${country}/` : `${base}int/` const params = url.searchParams.toString(); if (params) uri += `?${params}`; @@ -25,6 +24,6 @@ export async function onRequestGet({ request }) { return Response.redirect(uri, redirectStatus); } catch (e) { console.error(e); - return Response.redirect(`${base}/502/`, redirectStatus); + return Response.redirect(`${base}502/`, redirectStatus); } }