cookie is not set in the browser when using setCookie from h3 inside a Nuxt server endpoint #3028
ghost
started this conversation in
Help Wanted
Replies: 1 comment
-
thanks. moving to discussion until we have a minimal reproduction. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Environment
Nuxt (compatibilityVersion 4) v.3.15.2
node >20
Reproduction
Please check the description below
Describe the bug
Hi,
I'm using Nuxt with compatibilityVersion 4.
I have a server api endpoint that gets called from an external website, in the endpoint I receive some data that I put in my mongo database and then I have this setCookie
setCookie(event, 'session_key',
${sessionValue}.${signature}`, {httpOnly: true,
secure: process.env.NODE_ENV === 'production',
path: '/',
maxAge: 60 * 60 * 24 // 1 day
})
this is the log of my cookie in the server logs
Cookie Set: [ 'session_key=%7B%22senderID%22%3A%22S007%22%2C%22date%22%3A1737716793583%7D.gVks6cjZwsazQFGgcFTq%2F39eOFVFAMJ8I0Sw4tXR5fw%3D; Max-Age=86400; Path=/; HttpOnly; Secure; SameSite=Lax' ]
So it seems that the endpoint is triggered, my data gets inside my mongo db, but the cookie is not set in the browser.
I'm using nuxt-security allowing the first domain to make the POST request to my endpoint and everything seems working ok, I tried to disable nuxt-security but the problem is still there. The cookie is logged but not set in the browser.
Additional context
No response
Logs
Beta Was this translation helpful? Give feedback.
All reactions