Skip to content

Setting cookies during server redirect #3486

Closed Answered by gbj
dustypomerleau asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for the slow response.

I tried to create a small reproduction, but I found that it did set the cookie for me. But only temporarily, which was odd -- i.e., if I refresh the cookie is no longer there.

Then I realized that it was because the cookie was scoped to the path /api, which meant I was seeing it in the response from the server function -- but not back on the home route/the route to which I was redirecting.

In my repro, I was able to solve this by adding an appropriate Path to the cookie:

response.append_header(
    header::SET_COOKIE,
    HeaderValue::from_str(&format!("edgedb-pkce-verifier=foo; Path=/"))?,
);

YMMV — I am far from an expert at cookies.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dustypomerleau
Comment options

You must be logged in to vote
0 replies
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