From 5ac13d1f8e98c0e301218445bf610d5bf109ede5 Mon Sep 17 00:00:00 2001 From: XLor Date: Tue, 23 Jul 2024 20:52:36 +0800 Subject: [PATCH] fix(worker): redirect --- packages/worker/src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/index.ts b/packages/worker/src/index.ts index 2eff2f0e..8729b14e 100644 --- a/packages/worker/src/index.ts +++ b/packages/worker/src/index.ts @@ -14,7 +14,7 @@ app.use('*', prettyJSON()); app.get('/', async (c) => { return c.json({ - message: 'AnimeGarden - 動漫花園 3-rd party mirror site', + message: 'AnimeGarden - 動漫花園 3-rd party mirror site' }); }); @@ -37,8 +37,9 @@ app.onError((err, c) => { export default { async fetch(request: Request, env: Env, ctx: ExecutionContext) { - const destinationURL = "https://garden.breadio.wiki"; + const destinationURL = new URL(request.url); + destinationURL.host = 'garden.breadio.wiki'; const statusCode = 301; - return Response.redirect(destinationURL, statusCode); - }, + return Response.redirect(destinationURL.toString(), statusCode); + } };