mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
refactor: centralize API URL and internal API key management for improved maintainability
This commit is contained in:
@@ -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(() => ({}));
|
||||
|
||||
Reference in New Issue
Block a user