From d63d141e8c796e5a490dd6ceb4d50f29b67c3336 Mon Sep 17 00:00:00 2001 From: Akis Date: Tue, 6 Dec 2022 15:39:50 +0200 Subject: [PATCH] get api url from env --- .env.example | 1 + src/routes/+page.server.ts | 6 +++--- src/routes/contact/+page.server.ts | 2 +- src/routes/contact/+page.svelte | 2 +- src/routes/instances/+page.server.ts | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5816fa9 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +VITE_API_URL=https://api.projectsegfau.lt \ No newline at end of file diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 28fba08..7549f2b 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -3,9 +3,9 @@ import { compile } from "mdsvex"; export const load: PageServerLoad = async () => { return { - state: await fetch("https://api.projectsegfau.lt/api/v1/state/announcements").then((res) => res.json()), - announcements: await fetch("https://api.projectsegfau.lt/api/v1/announcements").then((res) => res.json()), - content: await fetch("https://api.projectsegfau.lt/api/v1/announcements").then((res) => res.json()).then((res) => compile(res.title)).then((res) => res.code) + 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) } } diff --git a/src/routes/contact/+page.server.ts b/src/routes/contact/+page.server.ts index ed76f18..d1bf91b 100644 --- a/src/routes/contact/+page.server.ts +++ b/src/routes/contact/+page.server.ts @@ -2,6 +2,6 @@ import type { PageServerLoad } from "../$types"; export const load: PageServerLoad = async () => { return { - state: await fetch("https://api.projectsegfau.lt/api/v1/state/form").then((res) => res.json()) + state: await fetch(import.meta.env.VITE_API_URL + "/api/v1/state/form").then((res) => res.json()) } } \ No newline at end of file diff --git a/src/routes/contact/+page.svelte b/src/routes/contact/+page.svelte index 796746a..43581b0 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 094b342..22cc4bf 100644 --- a/src/routes/instances/+page.server.ts +++ b/src/routes/instances/+page.server.ts @@ -1,5 +1,5 @@ import type { PageServerLoad } from "./$types"; export const load: PageServerLoad = async () => { - return await fetch("https://api.projectsegfau.lt/api/v1/status").then((res) => res.json()); + return await fetch(import.meta.env.VITE_API_URL + "/api/v1/status").then((res) => res.json()); } \ No newline at end of file