Closed Thinkscape closed 12 months ago
Hi,
thanks for the issue and the excellent reproduction. This is much appreciated! Cloning your project and running it I see the same behavior.
I'll see what I can find out what the culprit is 👍
I found the culprit: https://github.com/clerk/javascript/blob/0551488fb67fc6ec117e8d19796094c4601013d2/packages/nextjs/src/utils/response.ts#L11
In this line the cookies get removed:
The PR fixing this issue is merged, I'll let you know once it's released.
This has been fixed in @clerk/nextjs@4.27.4
Preliminary Checks
[X] I have reviewed the documentation: https://clerk.com/docs
[X] I have searched for existing issues: https://github.com/clerkinc/javascript/issues
[X] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
[X] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction / Replay Link
https://github.com/roev-co/clerk-corrupting-cookies
Publishable key
pk_test_c3VwZXJiLWdob3VsLTEzLmNsZXJrLmFjY291bnRzLmRldiQ
Description
Steps to reproduce
middleware.ts
withauthMiddleware()
usingafterAuth
callbackresponse.cookies.set()
to set 2 or more cookiesnext dev
Expected behavior:
Cookies get set. Cookies parameters are set.
Actual behavior:
Only the first cookie gets set. Parameters like
sameSite
andsecure
get ignored and not being sent to the browser.Background
next
.authMiddleware()
- works fine with vanila Next.js middleware functionRepro app
.env.local
npm install
next dev
first
second
third
, but it will only showfirst
Environment