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',