Merged in feat/redirect-add-logging (pull request #2105)

feat: add scandic-redirect logging

* feat: add scandic-redirect logging


Approved-by: Michael Zetterberg
This commit is contained in:
Arvid Norlin
2025-05-15 09:21:51 +00:00
parent 0b960200b9
commit 22a9202e7b

View File

@@ -52,11 +52,18 @@ export default async (req: Request) => {
? redirectUrl.slice(0, -1)
: redirectUrl;
if (redirectUrlWithoutTrailingSlash === body.pathname) {
console.log(
`[scandic-redirect] recieved ${body.pathname}, found ${redirectUrlWithoutTrailingSlash}, no-op`
);
return new Response("Not Found", { status: 404 });
}
console.log(
`[scandic-redirect] recieved ${body.pathname}, return ${redirectUrlWithoutTrailingSlash}, success`
);
return new Response(redirectUrlWithoutTrailingSlash);
}
}
console.log(`[scandic-redirect] recieved ${body.pathname}, not found`);
return new Response("Not Found", { status: 404 });
} catch (error) {
return new Response("Bad request", { status: 400 });