From e24e1d87698f563a6a4d24c485bec4c657bd27af Mon Sep 17 00:00:00 2001 From: "Yadong (Adam) Zhang" Date: Mon, 10 Nov 2025 04:45:56 +0800 Subject: [PATCH] fix(apps/web): enhance JWT response with token type and expiration details (#24841) * fix: enhance JWT response with token type and expiration details * fix: update email generation in createUsersFixture to use v4 UUID without dashes * revert: update email generation in createUsersFixture to use short-uuid for unique email identifiers --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Volnei Munhoz Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com> --- apps/web/app/api/auth/oauth/token/route.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/web/app/api/auth/oauth/token/route.ts b/apps/web/app/api/auth/oauth/token/route.ts index 44251412fe..d094de02c5 100644 --- a/apps/web/app/api/auth/oauth/token/route.ts +++ b/apps/web/app/api/auth/oauth/token/route.ts @@ -79,15 +79,28 @@ async function handler(req: NextRequest) { clientId: client_id, }; + const accessTokenExpiresIn = 1800; // 30 minutes + const access_token = jwt.sign(payloadAuthToken, secretKey, { - expiresIn: 1800, // 30 min + expiresIn: accessTokenExpiresIn, }); const refresh_token = jwt.sign(payloadRefreshToken, secretKey, { expiresIn: 30 * 24 * 60 * 60, // 30 days }); - return NextResponse.json({ access_token, refresh_token }, { status: 200 }); + // @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1 + return NextResponse.json( + { access_token, token_type: "bearer", refresh_token, expires_in: accessTokenExpiresIn }, + { + status: 200, + headers: { + "Content-Type": "application/json;charset=UTF-8", + "Cache-Control": "no-store", + Pragma: "no-cache", + }, + } + ); } export const POST = defaultResponderForAppDir(handler);