Error: apiService.js:180 Fehler beim Abrufen der Benutzerrechte
WIP: Es soll die Seiten auf DNS-Name erreichbar sein
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// services/apiService.js
|
||||
import * as config from "../config/config";
|
||||
import * as urls from "../config/urls";
|
||||
import SERVER_URL from "../config/urls";
|
||||
const url = new URL(window.location.origin);
|
||||
const originWithoutPort = `${url.protocol}//${url.hostname}`;
|
||||
|
||||
let timeoutId;
|
||||
|
||||
@@ -21,19 +23,22 @@ const fetchWithTimeout = async (url, options, timeout = 5000) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchGisStatusStations = async (idMap, idUser) => {
|
||||
export const fetchGisStatusStations = async () => {
|
||||
//idMap und idUser von URL Parameter hersuslesen
|
||||
const idMap = url.searchParams.get("m");
|
||||
const idUser = url.searchParams.get("u");
|
||||
// Verhindere wiederholte schnelle API-Aufrufe durch Debouncing
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(async () => {
|
||||
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL;
|
||||
//const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL;
|
||||
|
||||
try {
|
||||
// Verwende das Timeout für die API-Anfrage
|
||||
const response = await fetchWithTimeout(
|
||||
`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`,
|
||||
`${originWithoutPort}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -136,6 +141,9 @@ export const fetchDeviceNameById = async (idLD) => {
|
||||
// ----------------------------------------------
|
||||
// services/apiService.js
|
||||
export const fetchUserRights = async () => {
|
||||
//idMap und idUser von URL Parameter hersuslesen
|
||||
const idMap = url.searchParams.get("m");
|
||||
const idUser = url.searchParams.get("u");
|
||||
// Zähler für API-Aufrufe in localStorage speichern
|
||||
let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0;
|
||||
userRightsRequestCount++;
|
||||
@@ -143,7 +151,10 @@ export const fetchUserRights = async () => {
|
||||
console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, {
|
||||
console.log("originWithoutPort in fetchUserRights", originWithoutPort);
|
||||
console.log("idMap in fetchUserRights", idMap);
|
||||
console.log("idUser in fetchUserRights", idUser);
|
||||
const response = await fetch(`${originWithoutPort}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Connection: "close",
|
||||
|
||||
Reference in New Issue
Block a user