When I make a successful login attempt, before returning the JWT, I also return a cookie that contains the refresh token. But somehow the cookie is not set on the frontend (which is a basic Next app). This cookie is correctly set on localhost, but not when I deploy it to Netlify.
Hmm… setting cookies from functions is definitely possible. Are you seeing any error in the console? If so, it’d be great to see a screenshot. And either way, a request id would let us check our logs in case we see any clues there.
Thanks for your response and the example from futuregerald’s repo. I have made some updates to my GET profile route to be more similar with it. But I still do not receive the cookie in the frontend.
I do not see any errors in the console (in the functions tab of my app). I can share the response headers, which includes the request id:
Thanks so much, that’s helpful- checking our logs for that ID, I am seeing this error: "Failed to parse token" error="signature is invalid" in response to a GET request to jovial-fermi-0a9389.netlify.app/.netlify/functions/app/profile. Can you try logging the signed payload when deployed vs. locally and see if they differ?
Please excuse my negligence, that URL was under an authentication middleware and I believe the error message is a valid one. To correct this, I have created this public page https://app-starter.chesscoders.com/cookies.
Thanks for that! I didn’t see anything surprising in our logs, but I did confirm that the cookie wasn’t set I’ll put this in front of my colleagues in case they have any ideas about what the problem could be.
One alternative to try would be setting the cookie in the function response, like this: