feat: API-URLs dynamisch aus .env.local statt config.js
- Alle API-URLs nutzen jetzt `process.env.NEXT_PUBLIC_API_BASE_URL` - `fetchGisStationsMeasurements`, `fetchGisStationsStaticDistrict`, `fetchGisStationsStatusDistrict`, `fetchGisSystemStatic` angepasst - `idMap` und `idUser` werden dynamisch aus URL oder `.env.local` bezogen - Entfernte `config.js`-Abhängigkeit für API-URLs - `.env.local` erlaubt jetzt flexible Server-IPs ohne Code-Anpassung
This commit is contained in:
@@ -9,7 +9,7 @@ DB_PORT=3306
|
||||
# Public Settings (Client braucht IP/Domain)
|
||||
NEXT_PUBLIC_SERVER_URL="http://192.168.10.33" # oder evtl. später https://nodemap.firma.de
|
||||
NEXT_PUBLIC_ENABLE_GEOCODER=true
|
||||
NEXT_PUBLIC_USE_MOCK_API=true
|
||||
NEXT_PUBLIC_USE_MOCK_API=false
|
||||
NEXT_PUBLIC_DEBUG_LOG=true
|
||||
|
||||
# für Polylines/kabelstecken -> in Konextmenü "Station öffnen" "
|
||||
|
||||
@@ -1010,9 +1010,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
useInitGisSystemStatic();
|
||||
|
||||
//--------------------------------------
|
||||
useEffect(() => {
|
||||
console.log("GisStationsStaticDistrict aus Redux:", GisStationsStaticDistrict);
|
||||
}, [GisStationsStaticDistrict]);
|
||||
//---------------------------------------
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.26";
|
||||
export const APP_VERSION = "1.1.27";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// /redux/api/fromWebService/fetchGisStationsMeasurements.js
|
||||
import { mapGisStationsMeasurementsUrl } from "../../../config/config";
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export const fetchGisStationsMeasurements = async () => {
|
||||
const response = await fetch(mapGisStationsMeasurementsUrl);
|
||||
const response = await fetch(`${apiBaseUrl}/GisStationsMeasurements`);
|
||||
if (!response.ok) {
|
||||
throw new Error("GisStationsMeasurements konnte nicht geladen werden");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// /redux/api/fromWebService/fetchGisStationsStaticDistrict.js
|
||||
import { mapGisStationsStaticDistrictUrl } from "../../../config/config";
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export const fetchGisStationsStaticDistrict = async () => {
|
||||
const response = await fetch(mapGisStationsStaticDistrictUrl);
|
||||
const response = await fetch(`${apiBaseUrl}/GisStationsStaticDistrict`);
|
||||
if (!response.ok) {
|
||||
throw new Error("GisStationsStaticDistrict konnte nicht geladen werden");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// /redux/api/fromWebService/fetchGisStationsStatusDistrict.js
|
||||
import { mapGisStationsStatusDistrictUrl } from "../../../config/config";
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export const fetchGisStationsStatusDistrict = async () => {
|
||||
const response = await fetch(mapGisStationsStatusDistrictUrl);
|
||||
const response = await fetch(`${apiBaseUrl}/GisStationsStatusDistrict`);
|
||||
if (!response.ok) {
|
||||
throw new Error("GisStationsStatusDistrict konnte nicht geladen werden");
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
// /redux/api/fromWebService/fetchGisSystemStatic.js
|
||||
import { useSearchParams } from "next/navigation"; // Falls du Next.js 13+ nutzt
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function fetchGisSystemStatic() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const idMap = params.get("idMap") || "12"; // Fallback-Wert 12
|
||||
const idUser = params.get("idUser") || "484"; // Fallback-Wert 484
|
||||
|
||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL; // Dynamische Server-IP
|
||||
const idMap = params.get("idMap") || process.env.NEXT_PUBLIC_DEFAULT_ID_MAP || "12";
|
||||
const idUser = params.get("idUser") || process.env.NEXT_PUBLIC_DEFAULT_ID_USER || "484";
|
||||
|
||||
const response = await fetch(`${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`);
|
||||
const data = await response.json();
|
||||
|
||||
console.log("fetchGisSystemStatic API Response:", data); // ✅ Prüfen, ob API Daten liefert
|
||||
console.log("fetchGisSystemStatic API Response:", data);
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user