allow public access to / and /index.html

This commit is contained in:
Abel Luck 2026-02-26 16:22:35 +01:00
parent d91f1491f1
commit b052c3f8d8
2 changed files with 13 additions and 9 deletions

View file

@ -14,7 +14,7 @@
packages = forAllSystems (pkgs: { packages = forAllSystems (pkgs: {
nix-cache = pkgs.buildNpmPackage { nix-cache = pkgs.buildNpmPackage {
pname = "nix-cache"; pname = "nix-cache";
version = "0.1.2"; version = "0.1.3";
src = ./nix-cache; src = ./nix-cache;
npmDepsHash = "sha256-bIujU7pZa1ExCZOMOoxsTeLDSF1GuPN/oMSgiMhY/04="; npmDepsHash = "sha256-bIujU7pZa1ExCZOMOoxsTeLDSF1GuPN/oMSgiMhY/04=";
buildPhase = '' buildPhase = ''

View file

@ -91,6 +91,13 @@ export default {
return Response.redirect(url.toString(), 301); return Response.redirect(url.toString(), 301);
} }
if (url.pathname === '/') {
url.pathname = '/index.html';
}
const isPublic = url.pathname === '/index.html';
if (!isPublic) {
const authenticated = await authenticate(request, env); const authenticated = await authenticate(request, env);
if (!authenticated) { if (!authenticated) {
return new Response('Unauthorized', { return new Response('Unauthorized', {
@ -98,9 +105,6 @@ export default {
headers: { 'WWW-Authenticate': 'Bearer realm="nix-cache"' }, headers: { 'WWW-Authenticate': 'Bearer realm="nix-cache"' },
}); });
} }
if (url.pathname === '/') {
url.pathname = '/index.html';
} }
const cache = caches.default; const cache = caches.default;