Фикс ошибок

This commit is contained in:
2026-08-01 03:39:07 -07:00
parent bff945e701
commit 12f6384856
5 changed files with 114 additions and 22 deletions

View File

@@ -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);
},
};