From 6c46524ab3107e59e4bb1e7a55b09572398a314a Mon Sep 17 00:00:00 2001 From: Akis Date: Tue, 6 Dec 2022 17:00:23 +0200 Subject: [PATCH] fix env vars --- .gitignore | 6 +++--- src/routes/+page.server.ts | 7 ++++--- src/routes/contact/+page.server.ts | 4 +++- src/routes/contact/+page.svelte | 2 +- src/routes/instances/+page.server.ts | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 69c3f3f..dc61a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ node_modules /build /.svelte-kit /package -#.env -#.env.* -#!.env.example +.env +.env.* +!.env.example package-lock.json \ No newline at end of file diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 7549f2b..ec1236b 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,11 +1,12 @@ import type { PageServerLoad } from "./$types"; import { compile } from "mdsvex"; +import { env } from "$env/dynamic/private"; export const load: PageServerLoad = async () => { return { - state: await fetch(import.meta.env.VITE_API_URL + "/api/v1/state/announcements").then((res) => res.json()), - announcements: await fetch(import.meta.env.VITE_API_URL + "/api/v1/announcements").then((res) => res.json()), - content: await fetch(import.meta.env.VITE_API_URL + "/api/v1/announcements").then((res) => res.json()).then((res) => compile(res.title)).then((res) => res.code) + state: await fetch(env.VITE_API_URL + "/api/v1/state/announcements").then((res) => res.json()), + announcements: await fetch(env.VITE_API_URL + "/api/v1/announcements").then((res) => res.json()), + content: await fetch(env.VITE_API_URL + "/api/v1/announcements").then((res) => res.json()).then((res) => compile(res.title)).then((res) => res.code) } } diff --git a/src/routes/contact/+page.server.ts b/src/routes/contact/+page.server.ts index d1bf91b..0b36674 100644 --- a/src/routes/contact/+page.server.ts +++ b/src/routes/contact/+page.server.ts @@ -1,7 +1,9 @@ import type { PageServerLoad } from "../$types"; +import { env } from "$env/dynamic/private"; export const load: PageServerLoad = async () => { return { - state: await fetch(import.meta.env.VITE_API_URL + "/api/v1/state/form").then((res) => res.json()) + state: await fetch(env.VITE_API_URL + "/api/v1/state/form").then((res) => res.json()), + apiUrl: env.VITE_API_URL } } \ No newline at end of file diff --git a/src/routes/contact/+page.svelte b/src/routes/contact/+page.svelte index 43581b0..a1d9d14 100644 --- a/src/routes/contact/+page.svelte +++ b/src/routes/contact/+page.svelte @@ -21,7 +21,7 @@

Contact form

{#if data.state.enabled === true}
diff --git a/src/routes/instances/+page.server.ts b/src/routes/instances/+page.server.ts index 22cc4bf..7e20563 100644 --- a/src/routes/instances/+page.server.ts +++ b/src/routes/instances/+page.server.ts @@ -1,5 +1,6 @@ import type { PageServerLoad } from "./$types"; +import { env } from "$env/dynamic/private"; export const load: PageServerLoad = async () => { - return await fetch(import.meta.env.VITE_API_URL + "/api/v1/status").then((res) => res.json()); + return await fetch(env.VITE_API_URL + "/api/v1/status").then((res) => res.json()); } \ No newline at end of file