JWT cookieName option does not work #1882
-
Description 🐜The
How to reproduce ☕️Clone the example repo git clone https://github.com/nextauthjs/next-auth-example.git
cd next-auth-example
npm i Add the // In /pages/api/auth/[...nextauth].js
{
jwt: {
cookieName: "custom-name"
}
} This is not used by the application. It still uses In the source code for Lines 115 to 117 in 543f812 Screenshots / Logs 📽Chrome tools shows that the cookie name remains Contributing 🙌🏽Potentially interested in contributing, assuming I have understood the |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Did some digging, and it looks like this is the reminiscent of version 2.x 4167859#diff-2c2a1625654e55c4a251b587dc0196c4aba9c610825e56ce2b861762888c7155R29 In that case, the docs (And typescript Line 49 in 0eb4159 |
Beta Was this translation helpful? Give feedback.
-
Are you looking for an update to remove the option from the docs, or to re-implement the feature? I'm not clear on why it was removed in the first place. |
Beta Was this translation helpful? Give feedback.
-
Update the docs. To be honest, I don't know either, @iaincollins did it a long time ago, I wasn't around then yet, sorry. I think this is the particular diff that changed it: |
Beta Was this translation helpful? Give feedback.
-
Wait, sorry! Lines 107 to 124 in 0eb4159 The current code only implements a default, but if you provide a cookieName, it SHOULD be used after all 🤦 |
Beta Was this translation helpful? Give feedback.
-
using This Check the docs again: https://next-auth.js.org/configuration/options#jwt-helper It is a parameter for the You may also have to change it here: https://next-auth.js.org/configuration/options#cookies Do note that this can introduce security issues. Can you maybe explain why do you need to change the name of this cookie? |
Beta Was this translation helpful? Give feedback.
-
Here is a reproduction of it not working: https://replit.com/@userfront/next-auth-example#pages/api/auth/[...nextauth].js You can see when you log in (only Google is enabled) that the cookie is set to the default name. |
Beta Was this translation helpful? Give feedback.
using
getToken({cookieName: "some-name"})
do seem to work for me! Do you have a reproduction?This
seem to be in the incorrect place.
Check the docs again: https://next-auth.js.org/configuration/options#jwt-helper
It is a parameter for the
getToken()
method.You may also have to change it here: https://next-auth.js.org/configuration/options#cookies
Do note that this can introduce security issues. Can you maybe explain why do you need to change the name of this cookie?