Backend URL moved to env variable
This commit is contained in:
11
README.md
11
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
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|||||||
12
app/api.ts
12
app/api.ts
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user