fixes and improvements to env variables usage

This commit is contained in:
pluja
2023-10-27 16:21:43 +02:00
parent bded8f0dc6
commit f389df7c51
5 changed files with 12 additions and 15 deletions

View File

@@ -1,14 +1,13 @@
/** @type {import('./$types').PageLoad} */
import { currentTranscription } from '$lib/stores';
import { CLIENT_API_HOST } from '$lib/utils';
import { browser } from '$app/environment';
import { env } from '$env/dynamic/public';
export async function load({params}) {
// Fetch json from /api/transcriptions/{id}
let id = params.id;
// Use different endpoints for server-side and client-side
const endpoint = browser ? `${CLIENT_API_HOST}/api/transcriptions` : `${process.env.INTERNAL_API_HOST}/api/transcriptions`;
const endpoint = browser ? `${env.PUBLIC_API_HOST}/api/transcriptions` : `${env.PUBLIC_INTERNAL_API_HOST}/api/transcriptions`;
const response = await fetch(`${endpoint}/${id}`);
const ts = await response.json();
// Set currentTranscription to the fetched transcription