From 56b68a5b19b8ce50e40df8e37cb0e842d4d80996 Mon Sep 17 00:00:00 2001 From: headpatsyou Date: Fri, 13 Feb 2026 21:32:13 +0000 Subject: [PATCH] Update redirect flow --- src/app/gerir/route.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/gerir/route.ts b/src/app/gerir/route.ts index c33a5a2..6e6ac78 100644 --- a/src/app/gerir/route.ts +++ b/src/app/gerir/route.ts @@ -3,12 +3,13 @@ import { readConfig } from '@/utils/config' export async function GET(req: NextRequest) { const config = await readConfig() - const url = req.nextUrl.clone() - url.pathname = '/' - url.search = '' - if (config.authString) { - url.searchParams.set('auth', config.authString) - } + + // Use x-forwarded-host for proxied requests, fallback to host header + const host = req.headers.get('x-forwarded-host') || req.headers.get('host') || 'localhost:3000' + const protocol = req.headers.get('x-forwarded-proto') || 'https' + + const redirectPath = config.authString ? `/?auth=${config.authString}` : '/' + const redirectUrl = new URL(redirectPath, `${protocol}://${host}`) - return NextResponse.redirect(url) + return NextResponse.redirect(redirectUrl) }