allow overriding api url
All checks were successful
Nix Build / build (push) Successful in 1m12s

This commit is contained in:
Joakim Repomaa
2026-02-22 23:16:59 +02:00
parent 0ca657beb1
commit ea315d3a52
2 changed files with 5 additions and 6 deletions

View File

@@ -26,11 +26,11 @@
npmDepsHash = "sha256-2XxcsvKeYp+SVBx6Z2uB/34qUr7AderMxXKjm/kS8F0="; npmDepsHash = "sha256-2XxcsvKeYp+SVBx6Z2uB/34qUr7AderMxXKjm/kS8F0=";
API_PORT = "3000"; API_URL = "/api";
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
PUBLIC_API_PORT="''${API_PORT}" npm run build PUBLIC_API_URL="''${API_URL}" npm run build
runHook postBuild runHook postBuild
''; '';

View File

@@ -1,12 +1,11 @@
import type { NetworkStatus } from '$lib/types' import type { NetworkStatus } from '$lib/types'
import type { PageLoad } from './$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 ssr = false
export const load: PageLoad = async ({ fetch, url }) => { export const load: PageLoad = async ({ fetch }) => {
const apiUrl = `${url.protocol}//${url.hostname}:${PUBLIC_API_PORT}` const response = await fetch(PUBLIC_API_URL)
const response = await fetch(apiUrl)
const networkStatus: NetworkStatus = await response.json() const networkStatus: NetworkStatus = await response.json()
return { return {