Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What would be the way to pass cookies with requests? #115

Closed
jemmaengz1202 opened this issue Oct 12, 2019 · 3 comments
Closed

What would be the way to pass cookies with requests? #115

jemmaengz1202 opened this issue Oct 12, 2019 · 3 comments

Comments

@jemmaengz1202
Copy link

Is there a way to pass cookies with requests?
In axios, for example, one would do someting like this:

axios.create({
  withCredentials: true
})

And, using Fetch Api:

fetch('https://example.com', {
  credentials: 'include'  
})

Is there an option to send and recieve cookies to/from the server?

@alex-cory
Copy link
Collaborator

Is credentials: 'include' not working? That's how you should do it

@alex-cory
Copy link
Collaborator

In the fetch docs it says:

By default, fetch won't send or receive any cookies from the server, resulting in unauthenticated requests if the site relies on maintaining a user session (to send cookies, the credentials init option must be set).
Since Aug 25, 2017. The spec changed the default credentials policy to same-origin.

Are you testing in Chrome? If so, you need to have the credentials: 'include' or credentials: 'same-origin' set. Here's a video explaining it. You can also refer to the Request.credentials docs.

@alex-cory
Copy link
Collaborator

Closing this. If the issue persists or if this is still not working for some reason, please don't hesitate to reopen this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants