Service worker fetch event.request trying to find the referrer

Hi,

I’m trying to do something seemingly simple. I have a worker and I’m attempting to find the referrer of the request.

Here is a fragment…I just get “undefined”. I thought that with a worker I would have access to the referrer. Little help?

/Tim

addEventListener(‘fetch’, event => {
event.respondWith(CloudflareResponse(event.request));
})

async function CloudflareResponse(request) {

console.log(request.referrer);

return fetch(request);

}

request.headers.get('Referer')

3 Likes