Service worker tweaks in federated URL handling

pull/1232/head
Zef Hemel 2025-02-08 11:30:51 +01:00
parent 2de149dca1
commit 2978f4a8d6
1 changed files with 4 additions and 14 deletions

View File

@ -104,7 +104,8 @@ self.addEventListener("fetch", (event: any) => {
if ( if (
pathname === "/.auth" || pathname === "/.auth" ||
pathname === "/.logout" || pathname === "/.logout" ||
pathname === "/index.json" pathname === "/index.json" ||
pathname.startsWith("!")
) { ) {
return fetch(request); return fetch(request);
} else if (looksLikePathWithExtension(pathname)) { } else if (looksLikePathWithExtension(pathname)) {
@ -144,19 +145,8 @@ async function handleLocalFileRequest(
}, },
); );
} else if (path.startsWith("!")) { } else if (path.startsWith("!")) {
// Federated URL handling console.log("Passing on federated URL", path);
let url = path.slice(1); return fetch(request);
if (url.startsWith("localhost")) {
url = `http://${url}`;
} else {
url = `https://${url}`;
}
console.info("Proxying federated URL", path, "to", url);
return fetch(url, {
method: request.method,
headers: request.headers,
body: request.body,
});
} else { } else {
console.error( console.error(
"Did not find file in locally synced space", "Did not find file in locally synced space",