allow public access to / and /index.html
This commit is contained in:
parent
d91f1491f1
commit
b052c3f8d8
2 changed files with 13 additions and 9 deletions
|
|
@ -91,18 +91,22 @@ export default {
|
|||
return Response.redirect(url.toString(), 301);
|
||||
}
|
||||
|
||||
const authenticated = await authenticate(request, env);
|
||||
if (!authenticated) {
|
||||
return new Response('Unauthorized', {
|
||||
status: 401,
|
||||
headers: { 'WWW-Authenticate': 'Bearer realm="nix-cache"' },
|
||||
});
|
||||
}
|
||||
|
||||
if (url.pathname === '/') {
|
||||
url.pathname = '/index.html';
|
||||
}
|
||||
|
||||
const isPublic = url.pathname === '/index.html';
|
||||
|
||||
if (!isPublic) {
|
||||
const authenticated = await authenticate(request, env);
|
||||
if (!authenticated) {
|
||||
return new Response('Unauthorized', {
|
||||
status: 401,
|
||||
headers: { 'WWW-Authenticate': 'Bearer realm="nix-cache"' },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const cache = caches.default;
|
||||
let response = await cache.match(request);
|
||||
let range: Range | undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue