From ea315d3a527db870a51d23901037a5d1b37f5780 Mon Sep 17 00:00:00 2001 From: Joakim Repomaa Date: Sun, 22 Feb 2026 23:16:59 +0200 Subject: [PATCH] allow overriding api url --- flake.nix | 4 ++-- src/routes/+page.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index cc4ff14..ece9405 100644 --- a/flake.nix +++ b/flake.nix @@ -26,11 +26,11 @@ npmDepsHash = "sha256-2XxcsvKeYp+SVBx6Z2uB/34qUr7AderMxXKjm/kS8F0="; - API_PORT = "3000"; + API_URL = "/api"; buildPhase = '' runHook preBuild - PUBLIC_API_PORT="''${API_PORT}" npm run build + PUBLIC_API_URL="''${API_URL}" npm run build runHook postBuild ''; diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 7211504..16dd85a 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' +import { PUBLIC_API_URL } from '$env/static/public' export const ssr = false -export const load: PageLoad = async ({ fetch, url }) => { - const apiUrl = `${url.protocol}//${url.hostname}:${PUBLIC_API_PORT}` - const response = await fetch(apiUrl) +export const load: PageLoad = async ({ fetch }) => { + const response = await fetch(PUBLIC_API_URL) const networkStatus: NetworkStatus = await response.json() return {