nix-cache: redirect http to https

This commit is contained in:
Abel Luck 2026-02-26 14:45:11 +01:00
parent ea675c8818
commit d91f1491f1
3 changed files with 25 additions and 12 deletions

View file

@ -85,6 +85,12 @@ export default {
return new Response(null, { headers: { allow: allowedMethods.join(', ') } });
}
const url = new URL(request.url);
if (url.protocol !== 'https:') {
url.protocol = 'https:';
return Response.redirect(url.toString(), 301);
}
const authenticated = await authenticate(request, env);
if (!authenticated) {
return new Response('Unauthorized', {
@ -93,7 +99,6 @@ export default {
});
}
const url = new URL(request.url);
if (url.pathname === '/') {
url.pathname = '/index.html';
}