refactor: API-Port-Variable entfernt, dynamische Port-Nutzung eingeführt
- NEXT_PUBLIC_API_PORT_3000 entfernt - API-Aufrufe basieren jetzt auf window.location.hostname:3000 - kein Rebuild mehr bei IP-Änderung nötig - .env.local aufgeräumt - CHANGELOG.md auf 1.1.68 aktualisiert
This commit is contained in:
@@ -3,7 +3,16 @@ import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
|
||||
// API-Abruf für POI-Typen
|
||||
export const fetchPoiTypes = createAsyncThunk("poiTypes/fetchPoiTypes", async () => {
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_API_PORT_3000;
|
||||
let API_BASE_URL = "";
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
// Browser
|
||||
API_BASE_URL = `${window.location.protocol}//${window.location.hostname}:3000`;
|
||||
} else {
|
||||
// Server (z. B. SSR)
|
||||
API_BASE_URL = "http://localhost:3000"; // oder env-Fallback z. B. process.env.API_BASE_URL
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/poiTyp/readPoiTyp`);
|
||||
return await response.json();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user