Skip to content

Commit

Permalink
fix: added additional logs to debug a failed verification in auth mid…
Browse files Browse the repository at this point in the history
…dleware
  • Loading branch information
awinogrodzki committed Nov 6, 2024
1 parent dd4d24e commit 30ddc5e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/next/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ export async function authMiddleware(
options.experimental_enableTokenRefreshOnExpiredKidHeader ?? false
);
} catch (error: unknown) {
debug('Token verification failed', {
error,
isInstanceOfInvalidTokenError: error instanceof InvalidTokenError,
InvalidTokenError
});

if (error instanceof InvalidTokenError) {
debug(
`Token is missing or has incorrect formatting. This is expected and usually means that user has not yet logged in`,
Expand Down

0 comments on commit 30ddc5e

Please sign in to comment.