-
-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Environment
| Operating system | macOS 25.2.0 |
| CPU | Apple M1 Pro (8 cores) |
| Node.js version | v24.4.1 |
| nuxt/cli version | 3.32.0 |
| Package manager | pnpm@10.14.0 |
| Nuxt version | 4.2.2 |
| Nitro version | 2.12.9 |
| Builder | vite@7.3.1 |
| Config | auth, compatibilityDate, components, css, devtools, fonts, hooks, i18n, modules, runtimeConfig, vite |
| Modules | @nuxt/eslint@1.12.1, @nuxt/fonts@0.12.1, @nuxtjs/i18n@10.2.1, @sidebase/nuxt-auth@1.1.1, @pinia/nuxt@0.11.3, floating-vue/nuxt@5.2.2, @vueuse/nuxt@14.1.0 |
Reproduction
.
Describe the bug
Sorry, but discussion are not enabled in this repo, so I created a new issue, I hope you don't mind.
I use Keycloak auth to login in my app that we are migrating from Nuxt 2 @nuxtjs/auth-next, to Nuxt 4 @sidebase/nuxt-auth.
I need to send the Bearer token in the Authorization to my API.
After a few minutes, my API calls start to fail with 401 unauthorized.
I'm trying to understand the issue.
In my API requestInterceptor, if the token is expired, I use the refreshToken to get a new token before sending the request. While investigating, I found that data.value.token.exp from useAuth() is not the same thing as exp from the decoded Bearer token (when manually pasting it in jwt.io), is this normal/expected ?
| Source | Name | Timestamp | Date |
|---|---|---|---|
| @sidebase/nuxt-auth | token.exp * 1000 | 1771716538000 | Sat Feb 21 2026 18:28:58 GMT-0500 |
| jwt.io | Bearer exp | 1769124895 | Wed Jan 21 1970 06:25:24 GMT-0500 |
Since the value of data.value.token.exp is not expired, but the token is indeed expired, the request fails with 401 unauthorized. I believe the value of data.value.token.exp is the expiration of the cookie, and not the token, so I guess I would need to make the expiration shorter, but it shouldn't really matter... One problem is that keycloak doesn't have a clear duration for the token, if I go in the keycloak admin there are like 15 different expiration fields, and I don't know which one is used for which situation.
Additional context
No response