Please see the code below:
const res = await fetch(request);
if (res.status === 404) {
return new Response('', { status: 404, headers: { 'Location': 'https://go.tallyfy.com/404.html' } });
}
else {
return res;
}
Would this actually be the right way of doing it, instead?
const res = event.waitUntil(fetch(request));
if (res.status === 404) {
return new Response('', { status: 404, headers: { 'Location': 'https://go.tallyfy.com/404.html' } });
}
else {
return res;
}
There’s nothing else I want to do other than to fetch the response from the origin, check it’s a 404 or not and then proceed to finish.