Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cookies stripped when set in "headers" argument to fetch

ANSWERED

I'm trying to include cookies by including them in a fetch request, but they appear to be stripped by the time I receive them.  Here's the code:

 

let authenticator="...";

fetch("https://speechcode.com/calendar/fitbit", { method: "GET", headers: { "alpha": "bravo", "Cookie": `user=${authenticator}`} })...

The "alpha" header, on the other hand, does reach the back end.  And when browsers send the "Cookie" header, they are received.

 

Is something in fetch stripping the Cookie header?  If so, what do I have to do to include a cookie in my request?

 

Thanks.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I solved this problem by using a prior POST with authentication information to cause a cookie to be set, just as in a browser.

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

I solved this problem by using a prior POST with authentication information to cause a cookie to be set, just as in a browser.

Best Answer
0 Votes