Skip to content

Cross-Origin Cookie Issue: JWT Authentication Not Persisting Between Backend (Render) and Frontend (Vercel) #6394

Closed Answered by krzysdz
CH3T4N87 asked this question in Q&A
Discussion options

You must be logged in to vote

Your backend's login controller tries to set a cookie for your frontend domain - that's impossible.
You can set the cookie to be used in backend requests, but the cookie's domain should match the backend domain (otherwise browsers will reject it) and, since it is a third-party cookie, it must be marked as Partitioned (supported only in Chrome, but worked for me in Firefox 🤷).

If you don't want to gamble on CHIPS browser support, you could also use Storage Access API or just return the token in response, store it in LocalStorage and send e.g. in Authorization header using your JS client code.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@CH3T4N87
Comment options

@krzysdz
Comment options

Comment options

You must be logged in to vote
1 reply
@CH3T4N87
Comment options

Answer selected by CH3T4N87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants