Cookies in worker

I am doing fetch(event.request) in worker but seems like it does not send cookies it received from the browser along with the request.

I verified that event.request.headers have correct cookie headers. How do I verify if these cookie headers are passed along with fetch?

Hey @jai, I think you need to manually specify what headers you want to pass along to fetch. They don’t get passed along to your fetch function within your worker script (from what I understand).

Thank you @dmitry. I tried this but still no luck.

let myHeaders = new Headers(event.request.headers);
const myInit = {
  method: 'GET',
  headers: myHeaders
response = await fetch(url, myInit); 

It seems this still does not send cookie headers. When I add credentials: ‘include’ to myInit, it gives me 1101 exception error.

For someone stuck in similar situation.

worker was sending cookies by default. Problem was it was sending requests to http in place of https. I had to go to crypto and change ssl into full.

1 Like