From 0dad9b586c170bd603452f0043c9ac29ea36bf94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Veikko=20Lintuj=C3=A4rvi?= Date: Tue, 17 Jun 2025 21:52:28 +0300 Subject: [PATCH] Backend URL moved to env variable --- README.md | 11 +++++++++++ app/api.ts | 12 +++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3ee4823..499c7eb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ +# Lokaali kehitys + +## Ympäristömuuttujat + +Lisää projektin juureen `.env` tiedosto jossa sisältö: + +``` +API_URL=http://localhost:9090 +``` + +## Ja ei kun kovaa ajoa ```bash npm run dev ``` diff --git a/app/api.ts b/app/api.ts index d6b7dc7..602cbac 100644 --- a/app/api.ts +++ b/app/api.ts @@ -1,8 +1,6 @@ export const fetchCustomerData = async (id: string) => { - const baseUrl = "http://localhost:9090"; - try { - const response = await fetch(`${baseUrl}/loota/${id}`, { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/${id}`, { method: 'GET', }); if (!response.ok) { @@ -16,10 +14,8 @@ export const fetchCustomerData = async (id: string) => { } export const markBoxPickedUp = async (id: string) => { - const baseUrl = "http://localhost:9090"; - try { - const response = await fetch(`${baseUrl}/loota/`, { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -37,10 +33,8 @@ export const markBoxPickedUp = async (id: string) => { } export const markBoxDelivered = async (id: string) => { - const baseUrl = "http://localhost:9090"; - try { - const response = await fetch(`${baseUrl}/loota/`, { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/`, { method: 'POST', headers: { 'Content-Type': 'application/json',