Federation fix
This commit is contained in:
parent
82391682f6
commit
581edf92d5
@ -54,7 +54,7 @@ export async function renderTOC(reload = false) {
|
|||||||
});
|
});
|
||||||
// console.log("All headers", headers);
|
// console.log("All headers", headers);
|
||||||
if (!reload && cachedTOC === JSON.stringify(headers)) {
|
if (!reload && cachedTOC === JSON.stringify(headers)) {
|
||||||
console.log("TOC is the same, not updating");
|
// TOC is the same, not updating
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cachedTOC = JSON.stringify(headers);
|
cachedTOC = JSON.stringify(headers);
|
||||||
|
@ -455,10 +455,22 @@ export class HttpServer {
|
|||||||
async ({ params, response, request }) => {
|
async ({ params, response, request }) => {
|
||||||
const name = params[0];
|
const name = params[0];
|
||||||
const spaceServer = await this.ensureSpaceServer(request);
|
const spaceServer = await this.ensureSpaceServer(request);
|
||||||
console.log("Requested file", name);
|
console.log(
|
||||||
if (!request.headers.has("X-Sync-Mode") && name.endsWith(".md")) {
|
"Requested file",
|
||||||
|
name,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
name.endsWith(".md") && !request.headers.has("X-Sync-Mode") &&
|
||||||
|
request.headers.get("sec-fetch-mode") !== "cors"
|
||||||
|
) {
|
||||||
// It can happen that during a sync, authentication expires, this may result in a redirect to the login page and then back to this particular file. This particular file may be an .md file, which isn't great to show so we're redirecting to the associated SB UI page.
|
// It can happen that during a sync, authentication expires, this may result in a redirect to the login page and then back to this particular file. This particular file may be an .md file, which isn't great to show so we're redirecting to the associated SB UI page.
|
||||||
console.log("Request was without X-Sync-Mode, redirecting to page");
|
console.warn(
|
||||||
|
"Request was without X-Sync-Mode nor a CORS request, redirecting to page",
|
||||||
|
);
|
||||||
|
// Log all request headers
|
||||||
|
// for (const [key, value] of request.headers.entries()) {
|
||||||
|
// console.log("Header", key, value);
|
||||||
|
// }
|
||||||
response.redirect(`/${name.slice(0, -3)}`);
|
response.redirect(`/${name.slice(0, -3)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user