From e36e901ee3af9177acb28c215cf37fa098c4a7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Schr=C3=B6tler?= <niklas@allround.digital> Date: Sat, 9 Dec 2023 16:13:50 +0100 Subject: [PATCH] LayoutService: Implemented support for sub-urls --- src/config.ts | 1 + src/services/LayoutService.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/config.ts diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..79a3ff3 --- /dev/null +++ b/src/config.ts @@ -0,0 +1 @@ +export const BASE_URL = "/infoscreen"; // No trailing slash diff --git a/src/services/LayoutService.ts b/src/services/LayoutService.ts index 2b90cad..070cfcc 100644 --- a/src/services/LayoutService.ts +++ b/src/services/LayoutService.ts @@ -1,4 +1,5 @@ import {LayoutConfig} from "../types/LayoutConfig"; +import {BASE_URL} from "../config"; const NO_LAYOUT_CONFIG: LayoutConfig = { id: "", @@ -13,9 +14,9 @@ export class LayoutService { static async init(): Promise<void> { try { - const activeConfigs = await fetch("/activeConfigs.json").then(content => content.json()); + const activeConfigs = await fetch(BASE_URL + "/activeConfigs.json").then(content => content.json()); const configFetches = (activeConfigs as string[]) - .map(configPath => fetch(configPath).then(content => content.json())); + .map(configPath => fetch(BASE_URL + "/" + configPath).then(content => content.json())); LayoutService.configs = await Promise.all(configFetches); } catch (e) { -- GitLab