diff --git a/flake.nix b/flake.nix index 210af59..cc4ff14 100644 --- a/flake.nix +++ b/flake.nix @@ -26,9 +26,11 @@ npmDepsHash = "sha256-2XxcsvKeYp+SVBx6Z2uB/34qUr7AderMxXKjm/kS8F0="; + API_PORT = "3000"; + buildPhase = '' runHook preBuild - npm run build + PUBLIC_API_PORT="''${API_PORT}" npm run build runHook postBuild ''; diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 2f24947..7211504 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -1,12 +1,11 @@ import type { NetworkStatus } from '$lib/types' import type { PageLoad } from './$types' +import { PUBLIC_API_PORT } from '$env/static/public' export const ssr = false -const API_PORT = import.meta.env.PUBLIC_API_PORT ?? '8080' - export const load: PageLoad = async ({ fetch, url }) => { - const apiUrl = `${url.protocol}//${url.hostname}:${API_PORT}` + const apiUrl = `${url.protocol}//${url.hostname}:${PUBLIC_API_PORT}` const response = await fetch(apiUrl) const networkStatus: NetworkStatus = await response.json()