From 925ec86f4d5c083f0f6c4b8d84c12e700ee073f5 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Sat, 13 Dec 2025 14:33:20 -0600 Subject: [PATCH] hacky fix --- src/webpage/service.ts | 1 + src/webpage/utils/utils.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/webpage/service.ts b/src/webpage/service.ts index 6677fd2..24e1dd4 100644 --- a/src/webpage/service.ts +++ b/src/webpage/service.ts @@ -150,6 +150,7 @@ async function getfile(event: FetchEvent): Promise { let path = toPath(event.request.url); if (path === "/instances.json") { + //TODO the client shouldn't really even fetch this, it should just ask the SW for it return await fetch(path); } console.log("Getting path: " + path); diff --git a/src/webpage/utils/utils.ts b/src/webpage/utils/utils.ts index 52659f6..12d2fa3 100644 --- a/src/webpage/utils/utils.ts +++ b/src/webpage/utils/utils.ts @@ -4,6 +4,7 @@ import {Dialog} from "../settings.js"; import {fix} from "./cssMagic.js"; import {messageFrom, messageTo} from "./serviceType.js"; fix(); +const apiDoms = new Set(); let instances: | { name: string; @@ -35,7 +36,8 @@ export function setTheme() { export function getBulkUsers() { const json = getBulkInfo(); for (const thing in json.users) { - json.users[thing] = new Specialuser(json.users[thing]); + const user = (json.users[thing] = new Specialuser(json.users[thing])); + apiDoms.add(new URL(user.serverurls.api).host); } return json; } @@ -830,6 +832,19 @@ const checkInstance = Object.assign( }) => void; }, ); +{ + //TODO look at this and see if this can be made less hacky :P + const originalFetch = window.fetch; + window.fetch = function (input: RequestInfo | URL, init?: RequestInit) { + const url = new URL(input instanceof Request ? input.url : input, window.location.href); + if (apiDoms.has(url.host)) { + init = init || {}; + init.credentials ??= "include"; + } + + return originalFetch(input, init); + }; +} export {checkInstance}; export class SW {