I'm also hoping you might tell me it's hitting cache or something and I've since fixed the problem a
I'm also hoping you might tell me it's hitting cache or something and I've since fixed the problem and when the cache clears it'll work 
www-staging.foo.com, which by default will proxy using a CNAME to staging.actual-origin.com www-staging.foo.com as the URL. I've tried both fetch('www-staging.foo.com') and fetch(request) to no avail - both give the same result, assuming there's no caching funny-business going on.staging.actual-origin.com) requires a specific HTTP header to be set - this is done by a transform rule when proxied - but naturally as the worker intercepts that transform rule isn't applied. So in theory I just need to set that, then it should work
In your SaaS zone, create and set a fallback origin. Ensure the fallback origin only has an originless DNS record:
Example: service.example.com AAAA 100::

*/* (careful, this matches all traffic) and then you could use another to exclude your own domainawait fetch(request) goes to an origin, but there's nothing behind the fallback*/* instead?www-staging.foo.comwww-staging.foo.comstaging.actual-origin.comstaging.actual-origin.comfetch('www-staging.foo.com')const newRequestInit = {
headers: {
'X-custom-header': 'some-val',
}
}
const newRequest = new Request(
request,
new Request(request, newRequestInit)
);
return await fetch(newRequest)addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const fallbackOrigin = ''
try {
let response = await fetch(request)
if (response.ok) {
return response
}
throw new Error('Primary origin response not OK')
} catch (err) {
try {
const url = new URL(request.url)
url.hostname = new URL(fallbackOrigin).hostname
let fallbackResponse = await fetch(url.toString(), {
method: request.method,
headers: request.headers,
body: request.method !== 'GET' ? request.body : null,
})
return fallbackResponse
} catch (err) {
return new Response('Error fetching from the origin and fallback', {
status: 502,
statusText: 'Bad Gateway'
})
}
}
}addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
try {
// Attempt to get the response from the original site
let response = await fetch(request)
if (response.ok) {
return response
}
throw new Error('Primary origin response not OK')
} catch (err) {
return new Response('The primary origin is currently unavailable. Please try again later.', {
status: 503,
statusText: 'Service Unavailable',
headers: {
'Content-Type': 'text/plain'
}
})
}
}