forked from Rosetta/landing
Фикс ошибок
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
function withFreshHtml(response) {
|
||||
if (!response.headers.get('content-type')?.includes('text/html')) {
|
||||
return response;
|
||||
}
|
||||
|
||||
const headers = new Headers(response.headers);
|
||||
headers.set('Cache-Control', 'no-cache');
|
||||
|
||||
return new Response(response.body, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
const worker = {
|
||||
async fetch(request, env) {
|
||||
const response = await env.ASSETS.fetch(request);
|
||||
@@ -7,11 +22,12 @@ const worker = {
|
||||
request.method !== 'GET' ||
|
||||
!request.headers.get('accept')?.includes('text/html')
|
||||
) {
|
||||
return response;
|
||||
return withFreshHtml(response);
|
||||
}
|
||||
|
||||
const indexUrl = new URL('/index.html', request.url);
|
||||
return env.ASSETS.fetch(new Request(indexUrl, request));
|
||||
const indexResponse = await env.ASSETS.fetch(new Request(indexUrl, request));
|
||||
return withFreshHtml(indexResponse);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user