Skip to content

Commit 3b4a027

Browse files
fix: pass JWT via URL fragment instead of query param in mobile redirect (#146)
1 parent e43ca72 commit 3b4a027

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

apps/backend/src/routes/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ export async function authRoutes(app: FastifyInstance) {
117117
{ expiresIn: '30d' }
118118
);
119119

120-
// For mobile app: redirect with token as query param
120+
// For mobile app: redirect with token as URL fragment (not sent to servers, keeps token out of logs)
121121
const mobileRedirect = process.env.MOBILE_REDIRECT_URI;
122122
if (request.query.state?.startsWith('mobile_')) {
123-
return reply.redirect(`${mobileRedirect}?token=${token}`);
123+
return reply.redirect(`${mobileRedirect}#token=${token}`);
124124
}
125125

126126
// For web: set cookie and redirect
@@ -222,7 +222,7 @@ export async function authRoutes(app: FastifyInstance) {
222222

223223
if (request.query.state?.startsWith('mobile_')) {
224224
const mobileRedirect = process.env.MOBILE_REDIRECT_URI;
225-
return reply.redirect(`${mobileRedirect}?token=${token}`);
225+
return reply.redirect(`${mobileRedirect}#token=${token}`);
226226
}
227227

228228
reply.setCookie('token', token, {

0 commit comments

Comments
 (0)