Skip to content

Commit

Permalink
Service worker tweaks in federated URL handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Feb 8, 2025
1 parent 2de149d commit 2978f4a
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions web/service_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ self.addEventListener("fetch", (event: any) => {
if (
pathname === "/.auth" ||
pathname === "/.logout" ||
pathname === "/index.json"
pathname === "/index.json" ||
pathname.startsWith("!")
) {
return fetch(request);
} else if (looksLikePathWithExtension(pathname)) {
Expand Down Expand Up @@ -144,19 +145,8 @@ async function handleLocalFileRequest(
},
);
} else if (path.startsWith("!")) {
// Federated URL handling
let url = path.slice(1);
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,
});
console.log("Passing on federated URL", path);
return fetch(request);
} else {
console.error(
"Did not find file in locally synced space",
Expand Down

0 comments on commit 2978f4a

Please sign in to comment.