refactor: centralize API URL and internal API key management for improved maintainability

This commit is contained in:
2026-03-06 20:09:14 -05:00
parent 528456c168
commit d21265f443
7 changed files with 23 additions and 31 deletions
@@ -1,13 +1,11 @@
import type { PageServerLoad } from './$types';
import { env } from '$env/dynamic/private';
import { apiUrl } from '$lib/server/api';
import { error, isHttpError } from '@sveltejs/kit';
import { extractError } from '$lib/utils/misc';
const API_URL = env.VITE_API_URL ?? 'http://localhost:5050';
export const load: PageServerLoad = async ({ fetch }) => {
try {
const res = await fetch(`${API_URL}/api/stats`);
const res = await fetch(`${apiUrl}/api/stats`);
if (!res.ok) {
const json = await res.json().catch(() => ({}));