How to Set Cookies Manually in authorize Function with NextAuth.js v5? #12403
Unanswered
tranphuocloc070699
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm trying to implement a custom credentials provider in NextAuth.js v5 to sign in users using a username and password. The authentication works fine, but I'm running into an issue with cookies.
Here’s my situation:
In the authorize function, my external API sets a cookie in its response (via the Set-Cookie header).
However, this cookie is not reflected in the browser because the authorize function runs server-side, and the Set-Cookie header from the API response isn’t automatically applied to the browser.
How can I manually set this cookie for the browser inside the authorize function or elsewhere in the NextAuth flow? I want to ensure that the cookie from my API is properly set in the user's browser.

Beta Was this translation helpful? Give feedback.
All reactions