Fetch question
I developed a worker that fetches mirror page from another domain
addEventListener('fetch', function(event) {
event.respondWith(handleRequest(event.request)) // handleRequest is my own async function
});
In handleRequest, I have this:
const url = new URL(request.url);
const originUrl = url.toString().replace(mainURL, mirrorURL);
const originPage = await fetch(originUrl);
console.log(originPage.status)
It works fine, unless when the mirror page is responding 301 ==> the fetch result will give me the final/target URL, instead of giving me the 301.
Is that the way fetch works? Is it possible to tell it to return me 301, instead of having it follow the redirect trail?
Thanks
2 Replies