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

Cookies not send automatically with post request! #1076

Closed
varmeh opened this issue Sep 7, 2017 · 3 comments
Closed

Cookies not send automatically with post request! #1076

varmeh opened this issue Sep 7, 2017 · 3 comments

Comments

@varmeh
Copy link

varmeh commented Sep 7, 2017

Summary:
Cookies received in previous get call not send with following post command.

Details:
I am using the following sequence of calls to login into the backend.

axios.get(Url.csrfToken(), { withCredentials: true })
            .then(response => response.data)
            .then(token => axios.post(Url.authenticate(), { username, password }, {
                    headers: {
                        'content-type' : 'application/x-www-form-urlencoded',
                        'crsf-token' : `${token.csrfToken}`
                    },
                    withCredentials: true
                })
            )
            .then(response => console.log('completed'))
            .catch(error => console.log(error))

Cookies returned in set-cookie in response headers for get() is required by post().

But post() does not have any cookie in its header, leading to failure.

How could I fix it, please help?

Environment

  • react: 16.0.0-alpha.12
  • react-native: 0.47.2
  • iOS Simulator - version 10.0
@varmeh varmeh changed the title Cookies not automatically with post request! Cookies not send automatically with post request! Sep 7, 2017
@varmeh varmeh closed this as completed Sep 8, 2017
@pimvanderheijden
Copy link

@varmeh How did you fix this?

@chrisgillis
Copy link

Also curious

@pimvanderheijden
Copy link

pimvanderheijden commented Sep 25, 2017 via email

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants