forked from Rosetta/landing
19 lines
479 B
JavaScript
19 lines
479 B
JavaScript
const worker = {
|
|
async fetch(request, env) {
|
|
const response = await env.ASSETS.fetch(request);
|
|
|
|
if (
|
|
response.status !== 404 ||
|
|
request.method !== 'GET' ||
|
|
!request.headers.get('accept')?.includes('text/html')
|
|
) {
|
|
return response;
|
|
}
|
|
|
|
const indexUrl = new URL('/index.html', request.url);
|
|
return env.ASSETS.fetch(new Request(indexUrl, request));
|
|
},
|
|
};
|
|
|
|
export default worker;
|