Backend URL moved to env variable

This commit is contained in:
2025-06-17 21:52:28 +03:00
parent 80e31714ee
commit 0dad9b586c
2 changed files with 14 additions and 9 deletions

View File

@@ -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 ```bash
npm run dev npm run dev
``` ```

View File

@@ -1,8 +1,6 @@
export const fetchCustomerData = async (id: string) => { export const fetchCustomerData = async (id: string) => {
const baseUrl = "http://localhost:9090";
try { try {
const response = await fetch(`${baseUrl}/loota/${id}`, { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/${id}`, {
method: 'GET', method: 'GET',
}); });
if (!response.ok) { if (!response.ok) {
@@ -16,10 +14,8 @@ export const fetchCustomerData = async (id: string) => {
} }
export const markBoxPickedUp = async (id: string) => { export const markBoxPickedUp = async (id: string) => {
const baseUrl = "http://localhost:9090";
try { try {
const response = await fetch(`${baseUrl}/loota/`, { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -37,10 +33,8 @@ export const markBoxPickedUp = async (id: string) => {
} }
export const markBoxDelivered = async (id: string) => { export const markBoxDelivered = async (id: string) => {
const baseUrl = "http://localhost:9090";
try { try {
const response = await fetch(`${baseUrl}/loota/`, { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/loota/`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',