diff --git a/app/src/App.svelte b/app/src/App.svelte index 0de1362..b598616 100644 --- a/app/src/App.svelte +++ b/app/src/App.svelte @@ -6,13 +6,13 @@ import Controller from './routes/Controller.svelte'; import Config from './routes/Config.svelte'; import Health from './routes/SystemHealth.svelte'; - import location from './lib/location'; import Sidebar from './components/Sidebar.svelte'; import FileCache from './lib/cache'; + import { socketLocation } from './lib/location'; - export let url = window.location.pathname; + export let url = window.location.pathname onMount(() => { - connect(`ws://${location}`); + connect(socketLocation); registerFetchIntercept() }); @@ -21,9 +21,9 @@ window.fetch = async (...args) => { const [resource, config] = args; await FileCache.openDatabase(); - let file; + let file: BodyInit | Uint8Array | undefined | null; try { - file = await FileCache.getFile(resource.url); + file = await FileCache.getFile(resource.toString()); } catch (error) { console.log(error); } diff --git a/app/src/lib/location.ts b/app/src/lib/location.ts index dfb142e..6c00c47 100644 --- a/app/src/lib/location.ts +++ b/app/src/lib/location.ts @@ -1,3 +1,8 @@ -const location = import.meta.env.DEV ? "leika.local" : window.location.host +const forWeb = import.meta.env.MODE === "WEB" +const mock = import.meta.env.MODE === "MOCK" + +const location = mock ? `${window.location.hostname}:2096` : "leika.local" + +export const socketLocation = forWeb ? `wss://${window.location.hostname}:2096` : `ws://${location}` export default location; \ No newline at end of file