If you are not sure how to set up cookies with Node.js and HTTPS / HTTP requests to a specific page then this will definitely help you understand how you can do it.
I’ve confronted with this confusion too since I did not find much on the documentation of specific Node.js libraries that provide requests.
Lets say you have a Node.js https.get and you want to send a request to a specific page but you need a cookie in order to access that page for some reason. Here is how it should look :
1 2 3 4 5 6 7 8 9 10 11 | https.get( { hostname : 'mywebsite.com', path : '/my-folder', headers : { 'Cookie' : 'cookie_name=cookie_value' } }, function (response) { console.log('Request with cookie successfully sent !'); } |
If you want to send multiple cookies in one request then it would look something like this
1 | 'Cookie' : 'cookie_name=cookie_value; cookie2_name=cookie2_value; cookie3_name=cookie3_value' |
Hope this helps you ! Have a nice day