forked from Rosetta/landing
Add Sites worker entrypoint
This commit is contained in:
18
worker/index.js
Normal file
18
worker/index.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user