You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
Available memory (MB): 32768
Available CPU cores: 10
Binaries:
Node: 20.8.1
npm: 10.1.0
Yarn: 1.22.22
pnpm: 8.9.2
Relevant Packages:
next: 14.2.2 // There is a newer version (14.2.11) available, upgrade recommended!
eslint-config-next: 14.2.2
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
⚠ There is a newer version (14.2.11) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Which example does this report relate to?
none
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I am trying to set up an auth page and hit some errors while trying to set cookies from the server side, despite setting them in Server Action and Router Handler as the documentation stated. The idea is when the user visit the auth page, for example http://localhost:3010/auth?redirectTo=/en&tokenCsrf=1234&tokenRefresh=1234&tokenAccess=1234, the mock cookies are set to the browser during the SSR and redirect the user to the redirectTo page.
Setting secure: true will have the browser reject setting the cookie when it's not in a secure context. Can you remove that option and see if it resolves? Also try looking at the response headers on the POST request, I think the Set-Cookie header is indeed set.
@wyattjoh thank you for the suggestion. The secure: true did not fix it but when I added 'use client' to make the call on the front-end, the cookies are set correctly with or without secure flag
When I tried to set the cookie with Route Handler, calling the API endpoint from the server side, it doesn't work despite the response including the cookies I need to set. However, adding use client on the page and turning it into a client call sets the cookie correctly.
Verify canary release
Provide environment information
Which example does this report relate to?
none
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I am trying to set up an
auth
page and hit some errors while trying to set cookies from the server side, despite setting them in Server Action and Router Handler as the documentation stated. The idea is when the user visit the auth page, for examplehttp://localhost:3010/auth?redirectTo=/en&tokenCsrf=1234&tokenRefresh=1234&tokenAccess=1234
, the mock cookies are set to the browser during the SSR and redirect the user to theredirectTo
page.Here is my attempt to use Router Handler
The endpoint is called properly, in the server log, I see
but in the browser, nothing is set.
Attempt with Server action
Now, when visiting the URL, it just throw straight error
What am I missing here?
Expected Behavior
cookie.set
should work as doc described.To Reproduce
The code to reproduce is included in the description. I have nothing special included in the
layout.tsx
file.The text was updated successfully, but these errors were encountered: