From 66ab00a1743ec65deec7a20050230b704ffa5b16 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 30 Aug 2023 15:24:06 +0200 Subject: [PATCH] [client] Set config.host to instance domain instead of address.host --- packages/client/src/config.ts | 6 +++++- packages/client/src/init.ts | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/client/src/config.ts b/packages/client/src/config.ts index 1e354b087..dad6a82c8 100644 --- a/packages/client/src/config.ts +++ b/packages/client/src/config.ts @@ -3,7 +3,11 @@ const siteName = ( document.querySelector('meta[property="og:site_name"]') as HTMLMetaElement )?.content; -export const host = address.host; +export function setHost(newHost: string): void { + host = newHost; +} + +export let host = address.host; export const hostname = address.hostname; export const url = address.origin; export const apiUrl = `${url}/api`; diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index a84fd1f0b..fdbb119da 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -32,7 +32,7 @@ import { compareVersions } from "compare-versions"; import widgets from "@/widgets"; import directives from "@/directives"; import components from "@/components"; -import { version, ui, lang, host } from "@/config"; +import { version, ui, lang, setHost } from "@/config"; import { applyTheme } from "@/scripts/theme"; import { isDeviceDarkmode } from "@/scripts/is-device-darkmode"; import { i18n } from "@/i18n"; @@ -180,6 +180,7 @@ function checkForSplash() { fetchInstanceMetaPromise.then(() => { localStorage.setItem("v", instance.version); + setHost(new URL(instance.uri).host); // Init service worker initializeSw();