mirror of
https://github.com/KevinMidboe/planetposen-frontend.git
synced 2025-12-29 21:11:02 +00:00
Use hooks to check env and rewrite API call url if localhost
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch }) => {
|
||||
let url = '/api/warehouse';
|
||||
if (dev || env.API_HOST) {
|
||||
url = (env.API_HOST || 'http://localhost:30010').concat(url);
|
||||
}
|
||||
|
||||
const res = await fetch(url);
|
||||
const res = await fetch('/api/warehouse');
|
||||
const warehouse = await res.json();
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user