How to specify headers or cookies to send with connection requests from Node.js
See original GitHub issueI’m connecting to a primus server from another node.js process and I need to attach a session cookie to the initial http request. When connecting from a browser cookies are automatically attached. I can’t seem to find any documentation on how to do this from a non-browser/Node.js client. The transformer I’m using is websockets
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How can I send cookie using NodeJs request GET module?
After a few hours I've found a solution, instead of : //requesting data request({ url: 'http://localhost/delivery-stats', method: "GET", header: ...
Read more >How do I create a HTTP Client Request with a cookie - Edureka
I've got a node.js Connect server that checks the request's cookies. ... 'cookie' header for this, but I'm not sure how to set...
Read more >How to set cookies when send a request in node ? · Issue #943
The cookies need to be passed into the headers object. Axios.request({ url: "http://example.com" ...
Read more >Understanding Cookies and Implementing them in Node.js
Step 1 - Set a cookie. We will set a route that will save a cookie in the browser. In this case, the...
Read more >Using HTTP cookies - MDN Web Docs
After receiving an HTTP request, a server can send one or more Set-Cookie headers with the response. The browser usually stores the cookie...
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 FreeTop 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
Top GitHub Comments
You can use the
transport
option. See https://github.com/primus/primus#connecting-from-the-browser. For example in your case:@lpinca fortunately this is node, and I can just do it manually. For anyone who comes across this. You can add headers to the initial
GET
request here, and you can add headers for thewebsocket
connection here. Just add a headers object to the options passed into theWebsocketDriver
. Thanks for the prompt response pushing me in the right direction.