Skip to content

Commit 0f25f92

Browse files
committed
feat: manaage preview url in auth
1 parent 7d0be11 commit 0f25f92

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app/auth/callback/route.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ export async function GET(request: Request) {
5252

5353
const forwardedHost = request.headers.get("x-forwarded-host")
5454
const isLocal = process.env.NODE_ENV === "development"
55+
const host = forwardedHost || new URL(request.url).hostname
5556

56-
const redirectUrl = isLocal
57-
? `${origin}${next}`
58-
: forwardedHost
59-
? `https://${forwardedHost}${next}`
60-
: `${origin}${next}`
57+
let baseUrl = ""
58+
if (isLocal) {
59+
baseUrl = origin
60+
} else {
61+
baseUrl = `https://${host}`
62+
}
63+
64+
const redirectUrl = `${baseUrl}${next}`
6165

6266
return NextResponse.redirect(redirectUrl)
6367
}

0 commit comments

Comments
 (0)