Skip to content

Commit ed0e31d

Browse files
committed
Fix CLI auth sign-in redirect on hosted web
1 parent ca059e9 commit ed0e31d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

apps/web/src/routes/auth/cli.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ export const Route = createFileRoute("/auth/cli")({
3535
)
3636
}
3737

38-
return Response.redirect(
39-
`${authRoutes.signIn}?returnPathname=${encodeURIComponent(returnPathname)}`,
40-
307
41-
)
38+
return Response.redirect(signInRedirectUrl(request, returnPathname), 307)
4239
}
4340

4441
await approveCliDeviceLogin(code, auth)
@@ -52,6 +49,12 @@ export const Route = createFileRoute("/auth/cli")({
5249
},
5350
})
5451

52+
function signInRedirectUrl(request: Request, returnPathname: string): string {
53+
const target = new URL(authRoutes.signIn, request.url)
54+
target.searchParams.set("returnPathname", returnPathname)
55+
return target.href
56+
}
57+
5558
function safeUserCode(value: string | null): string | undefined {
5659
const code = value?.trim().toUpperCase()
5760

0 commit comments

Comments
 (0)