🧑‍💻 add environment variable for url in frontend

Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
Sindre Kjelsrud 2024-05-02 16:31:34 +02:00
parent c5e45424ea
commit f08bd430f3
Signed by untrusted user who does not match committer: sidski
GPG key ID: D2BBDF3EDE6BA9A6
7 changed files with 18 additions and 6 deletions

2
frontend/.env.example Normal file
View file

@ -0,0 +1,2 @@
# URL variable
VITE_URL="http://localhost:8080"

View file

@ -1,3 +1,5 @@
const URL = import.meta.env.VITE_URL;
interface Question {
QuestionID: number;
QuestionText: string;
@ -22,7 +24,7 @@ interface QAData {
export const getUserQuestions = async (
respondentID: number
): Promise<QAData> => {
let url = `https://helseundersokelsen.online/userquestions?respondentID=${respondentID}`;
let url = `${URL}/userquestions?respondentID=${respondentID}`;
const response = fetch(url, {
method: "GET",

View file

@ -1,5 +1,7 @@
const URL = import.meta.env.VITE_URL;
export const postBugData = async (bugText: string) => {
let url = "https://helseundersokelsen.online/submitbug";
let url = `${URL}/submitbug`;
const response = fetch(url, {
method: "POST",

View file

@ -1,5 +1,7 @@
const URL = import.meta.env.VITE_URL;
export const postEvaluationData = async (evaluationText: string) => {
let url = "https://helseundersokelsen.online/submiteval";
let url = `${URL}/submiteval`;
const response = fetch(url, {
method: "POST",

View file

@ -1,8 +1,10 @@
const URL = import.meta.env.VITE_URL;
export const postFormData = async (
respondentID: number,
allFormAnswers: string
) => {
let url = "https://helseundersokelsen.online/submitanswers";
let url = `${URL}/submitanswers`;
const response = fetch(url, {
method: "POST",

View file

@ -1,3 +1,5 @@
const URL = import.meta.env.VITE_URL;
interface postUserformDataReponse {
respondentID: number;
}
@ -12,7 +14,7 @@ export const postUserformData = async (
county: string,
submit_date: string
): Promise<postUserformDataReponse> => {
let url = "https://helseundersokelsen.online/submituserform";
let url = `${URL}/submituserform`;
let personnel = healthcare_personnel == "Ja" ? true : false;
let licensed = is_licensed == "Ja" ? true : false;
let answered_before = has_answered_before == "Ja" ? true : false;

View file

@ -1,4 +1,4 @@
import adapter from "@sveltejs/adapter-vercel";
import adapter from "@sveltejs/adapter-auto";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
/** @type {import('@sveltejs/kit').Config} */