From 0ba922634204fc4c625af54d74360caa933320de Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:24:31 +0800 Subject: [PATCH] chore: rewrite (#2693) --- src/middleware.ts | 13 +++++++++++++ vercel.json | 14 +------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index 79519af4c4..d8dd8ee539 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -24,6 +24,19 @@ export async function middleware(request: NextRequest) { const pathname = request.nextUrl.pathname; request.headers.set('X-URL', request.url); + console.log('DEBUG: middleware'); + console.log({ + url: request.url, + nextUrl: request.nextUrl, + pathname, + }); + + if (request.nextUrl.host === 'cz.firefly.social') { + return NextResponse.rewrite(new URL('/activity/cz', request.url), { + request, + }); + } + if (isMatchedDiscoverPage(pathname)) { return NextResponse.rewrite(new URL(`/discover${pathname}`, request.url), { request, diff --git a/vercel.json b/vercel.json index 2874af1717..ebac7fba0f 100644 --- a/vercel.json +++ b/vercel.json @@ -11,17 +11,5 @@ ] } ], - "redirects": [], - "rewrites": [ - { - "source": "/", - "has": [ - { - "type": "host", - "value": "cz.firefly.social" - } - ], - "destination": "/activity/cz" - } - ] + "redirects": [] }