Unable to read set-cookie header in node
See original GitHub issueFirst sanity check:
❯ curl -I "https://httpbin.org/cookies/set?a=1"
HTTP/1.1 302 FOUND
Connection: keep-alive
Server: meinheld/0.6.1
Date: Tue, 13 Jun 2017 15:25:30 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 223
Location: /cookies
Set-Cookie: a=1; Path=/
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.00121402740479
Via: 1.1 vegur
Compare with Axios:
import Axios from "axios"
it("axios supports set-cookie", () =>
Axios.request({
method: "get",
url: "https://httpbin.org/cookies/set?a=1"
}).then(res => {
expect(res.headers["set-cookie"]).toMatch(/a=1/)
}))
● axios supports set-cookie
expect(string)[.not].toMatch(expected)
string value must be a string.
Received: undefined
Releatd https://github.com/mzabriskie/axios/issues/295. Am I missing something?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Can't get set-cookie from header in response with NodeJS
I think you are requesting two different URLs/requests. wget is seeing text/html and other headers, whereas the node requests are seeing ...
Read more >axios cookie header not working - You.com | The AI Search ...
As it seems, it is not possible to read the Set-Cookie header via Axios, ... cookie value not being set in the request...
Read more >Cookies, document.cookie - The Modern JavaScript Tutorial
Cookies are usually set by a web-server using the response Set-Cookie HTTP-header. Then, the browser automatically adds them to (almost) ...
Read more >set-cookie-parser - npm
Parses set-cookie headers into objects. ... Start using set-cookie-parser in your project by running `npm i set-cookie-parser`.
Read more >Understanding Cookies and Implementing them in Node.js
//a get route for adding a cookie app.get('/setcookie', (req, res) => { res ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually just did some testing, that specific site sets the header and does a 302 redirect, Axios isn’t setting the cookie before following the redirect, meaning you just get sent to
https://httpbin.org/cookies/
with no cookie set.You can see the cookie with this code:
This is still an issue that we ought to discuss about. I just sent a
GET
request to http://httpbin.org/headers as:And I am getting all the responses, except for the cookie.