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

How can i get set-cookie header ? #295

Closed
lu911 opened this issue Apr 14, 2016 · 15 comments
Closed

How can i get set-cookie header ? #295

lu911 opened this issue Apr 14, 2016 · 15 comments

Comments

@lu911
Copy link

lu911 commented Apr 14, 2016

Hello.

"Set-Cookie" header exist in HTTP response header. But axios response didn't have "set-cookie" header.

Response header have only "content-type".

How can i get "set-cookie" header ?

@lu911 lu911 changed the title How can i get response set-cookie ? How can i get set-cookie header ? Apr 14, 2016
@lu911 lu911 closed this as completed Apr 14, 2016
@zsajjad
Copy link

zsajjad commented Apr 10, 2017

u found the solution?

@machineghost
Copy link

There is in fact a response.headers['set-cookie'] (I'm guessing that this was the solution found).

@rmartins90
Copy link

Can't find it too. Does anyone have any hint on this?

@ViswanathLekshmanan
Copy link

Any update ?

@MuraraAllan
Copy link

there is a "set-cookies" in response headers.

@sunnynegi
Copy link

Same problem unable to get set cookies from the header also try with withcredential : true. Any help on this

@ankitsinghaniyaz
Copy link

I'm also facing this. The cookie is there on the network tab, but nothing inside the response from axios.

@sunnynegi
Copy link

ankitsinghaniyaz Use withCredentials: true, in axiios they will help.
method: 'GET', url: BACKEND_URL+'/notification/new/?pageNum='+pageNum+'&pageSize='+resultSize, withCredentials: true, headers : {'Content-Type': 'application/x-www-form-urlencoded'}
This one work for me.

@ankitsinghaniyaz
Copy link

ankitsinghaniyaz commented Apr 16, 2018

So I had some gaps in my knowledge regarding how cookies work. Putting it here so that others can benefit from this.

  1. HTTP ONLY (Secure) cookies cannot be accessed in JavaScript. If you try to read some token, etc from a secure cookie it's not going to work.
  2. Cross-domain cookies cannot be accessed. In case you are building a single page application and your server is on a different domain. You cannot access the cookies on your SPA. The withCredentials flag will just make sure that the network calls made include the cookies and accept any incoming cookies.

I hope this will help someone. :)

@gil-air-may
Copy link

So I had some gaps in my knowledge regarding how cookies work. Putting it here so that others can benefit from this.

  1. HTTP ONLY (Secure) cookies cannot be accessed in JavaScript. If you try to read some token, etc from a secure cookie it's not going to work.
  2. Cross-domain cookies cannot be accessed. In case you are building a single page application and your server is on a different domain. You cannot access the cookies on your SPA. The withCredentials flag will just make sure that the network calls made include the cookies and accept any incoming cookies.

I hope this will help someone. :)

This saved me a lot of time. Thank you !

@enBonnet
Copy link

Look this master https://stackoverflow.com/questions/53898031/how-to-set-cookies-express-react-js/55804086#55804086

@asmakhalfallah2018
Copy link

Did you find solution to get the value of set-cookie please ? adding withCredentials: true doesn't fix the issue

@enBonnet
Copy link

Hey @asmakhalfallah2018 look at this https://stackoverflow.com/questions/53898031/how-to-set-cookies-express-react-js/55804086#55804086

@lromor
Copy link

lromor commented Dec 5, 2019

@ankitsinghaniyaz That answer is only true if considering the usage of axios inside a browser.
There are many applications where axios is used in a server context to do SSR.

@rohanshar
Copy link

Did anyone here find a solution ? None of the above solutions are solving it when axios is running on the server.

@axios axios locked and limited conversation to collaborators May 21, 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