Federated URL backend handling
parent
7442aac7e0
commit
21c8cd6e7a
|
@ -344,6 +344,17 @@ export class HttpServer {
|
||||||
response.body = "Not exposed";
|
response.body = "Not exposed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Handle federated links through a simple redirect, only used for attachments loads with service workers disabled
|
||||||
|
if (name.startsWith("!")) {
|
||||||
|
let url = name.slice(1);
|
||||||
|
if (url.startsWith("localhost")) {
|
||||||
|
url = `http://${url}`;
|
||||||
|
} else {
|
||||||
|
url = `https://${url}`;
|
||||||
|
}
|
||||||
|
response.redirect(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const fileData = await spacePrimitives.readFile(
|
const fileData = await spacePrimitives.readFile(
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Client } from "./client.ts";
|
import { Client } from "./client.ts";
|
||||||
import { EditorSelection, EditorView } from "./deps.ts";
|
import { EditorSelection } from "./deps.ts";
|
||||||
|
|
||||||
class PageState {
|
class PageState {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -147,6 +147,16 @@ 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: "GET", headers: request.headers });
|
||||||
} else {
|
} else {
|
||||||
console.error(
|
console.error(
|
||||||
"Did not find file in locally synced space",
|
"Did not find file in locally synced space",
|
||||||
|
|
Loading…
Reference in New Issue