Is access to event.request.headers
limited in workers?
To illustrate, I’ve got this simple worker basically logging the request headers:
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
console.log(new Map(request.headers))
return fetch("https://welcome.developers.workers.dev");
}
The weird thing is that it works as expected here: https://cloudflareworkers.com/#496e8336d13db706cc66f17f655cce7d:https://tutorial.cloudflareworkers.com
, but not in a real worker.
In the real worker only host
and x-forwarded-proto
is logged. From docs and other examples, it seems like more headers should be available… I need to use the header values for logic in my workers.
FWIW, I’m on a paid plan.