Token cookie is not saved with Nuxt 3
Version
@nuxtjs/strapi: 1.0.0-27336403.27afa67 nuxt: 3.0.0-27333638.5ab1816
Steps to reproduce
Use the example application to log in with strapi.
What is Expected?
The JWT token should be stored in cookies
What is actually happening?
No cookie is stored. So token cannot be reused between pages or sessions.
Workaround
I'm saving the cookie from the page after the login method. Then it can be used in other pages. I saw some messages stating useCookie cannot be used in composable right now.
Hi @dsciamma,
Have you tried using the latest version of nuxt3? I think a fix has been made about this.
Let me know if it fixes your issue.
Closing this for now, feel free to reopen if your problem persists.
Sorry, I haven't seen your previous comment. I'll try with the new version of Nuxt3 and I'll reopen the ticket if needed.
I got this issues and I followed the documentation, when I refresh the page, the user is logged out all the time
Have you tried setting the path to / or setting a maxAge?
export default defineNuxtConfig({
strapi: {
cookie: {
path: '/',
maxAge: 30 * 24 * 60 * 60
}
}
})
Same for me. I don't encounter this problem in dev mode, but after building for prod,useStrapiUser() as well as useStrapiToken() returns null, although cookie is sent in the request.
In the nuxt.config.js I have
strapi: {
url: process.env.NUXT_ENV_STRAPI_API_URL,
prefix: '/',
version: 'v4',
cookie: {
path: '/',
maxAge: 60 * 60 * 24 * 7,
//httpOnly: true,
//secure: true,
sameSite: true,
},
cookieName: 'strapi_jwt',
entities: ['user'],
},