get api url from env

This commit is contained in:
Akis 2022-12-06 15:39:50 +02:00
parent e2b9b84457
commit d63d141e8c
Signed by untrusted user: akis
GPG Key ID: 267BF5C6677944ED
5 changed files with 7 additions and 6 deletions

1
.env.example Normal file
View File

@ -0,0 +1 @@
VITE_API_URL=https://api.projectsegfau.lt

View File

@ -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)
}
}

View File

@ -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())
}
}

View File

@ -21,7 +21,7 @@
<h2>Contact form</h2>
{#if data.state.enabled === true}
<Form
action="https://api.projectsegfau.lt/api/v1/form"
action="{import.meta.env.VITE_API_URL}/api/v1/form"
method="POST"
id="contact-form"
>

View File

@ -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());
}