Update redirect flow

This commit is contained in:
headpatsyou 2026-02-13 21:32:13 +00:00
parent 737998bd6d
commit 56b68a5b19

View file

@ -3,12 +3,13 @@ import { readConfig } from '@/utils/config'
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
const config = await readConfig() const config = await readConfig()
const url = req.nextUrl.clone()
url.pathname = '/' // Use x-forwarded-host for proxied requests, fallback to host header
url.search = '' const host = req.headers.get('x-forwarded-host') || req.headers.get('host') || 'localhost:3000'
if (config.authString) { const protocol = req.headers.get('x-forwarded-proto') || 'https'
url.searchParams.set('auth', config.authString)
} const redirectPath = config.authString ? `/?auth=${config.authString}` : '/'
const redirectUrl = new URL(redirectPath, `${protocol}://${host}`)
return NextResponse.redirect(url) return NextResponse.redirect(redirectUrl)
} }