#10 customize base url for view and api via env variables
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"dev": "PUBLIC_BASE_API_URL=http://localhost:8080 vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { PUBLIC_BASE_API_URL } from '$env/static/public';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Auth } from 'firebase/auth';
|
||||
import { goto } from '$app/navigation';
|
||||
@@ -17,7 +18,7 @@
|
||||
const formData = new FormData(form);
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:8080/workout', {
|
||||
const response = await fetch(PUBLIC_BASE_API_URL + '/workout', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + (await auth?.currentUser?.getIdToken())
|
||||
@@ -49,7 +50,7 @@
|
||||
|
||||
async function fetchWorkouts() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:8080/workout', {
|
||||
const response = await fetch(PUBLIC_BASE_API_URL + '/workout', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + (await auth?.currentUser?.getIdToken())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user