Access response cookies? #2316
-
My backend automatically attaches sessionid and csrf tokens as How should I go about accessing those cookies so I can store them in the browser's cookie jar. I think there must be a way to use an exchange to, whenever I receive a Btw: using Svelte in the frontend. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey Lucas 👋
With any other kind of header, this is totally the route to take! Unfortunately, for security reasons, it looks like we wouldn't be able to access cookie information from a response. Am I right in thinking your issue is that cookies aren't being passed in future requests? If the request is on the same origin, you should see cookies being included in any request by default. For cross origin requests, you might need to tell the browser to include cross-origin cookies. const urql = createClient({
url: "https://some-cross-origin.domain"
fetchOptions: {
credentials: 'include'
}
}); |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm having a similar issue but on the back-end during SSR. I am awaiting a request that receives a token cookie. The cookie then needs to be attached to the subsequent requests. This is not a problem in the browser since it attaches the cookies automatically, but no such thing happens in Node. Any chance to expose response cookies to exchanges on the server side? |
Beta Was this translation helpful? Give feedback.
Hey Lucas 👋
With any other kind of header, this is totally the route to take! Unfortunately, for security reasons, it looks like we wouldn't be able to access cookie information from a response.
Am I right in thinking your issue is that cookies aren't being passed in future requests?
If the request is on the same origin, you should see cookies being included in any request by default. For cross origin requests, you might need to tell the browser to include cross-origin cookies.