IP kommt von window und nicht von.env.local, weil in CHIPTOOL kann die IP eingestellt werden

This commit is contained in:
ISA
2024-10-21 12:25:16 +02:00
parent 328b1d8a0e
commit 6f26e1b503
5 changed files with 111 additions and 72 deletions

View File

@@ -4,7 +4,9 @@ import Kue705FO from "../../components/modules/Kue705FO";
function Kabelueberwachung() {
//const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
const apiUrl = `https://${window.ip}:443`;
const [isClient, setIsClient] = useState(false);
const [apiUrl, setApiUrl] = useState("");
const [activeRack, setActiveRack] = useState(1); // Track the active rack
const [kueIso, setKueIso] = useState([]); // State to store isolation values
const [kueName, setKueName] = useState([]); // State to store the KUE names
@@ -16,7 +18,15 @@ function Kabelueberwachung() {
const changeRack = (rack) => {
setActiveRack(rack);
};
useEffect(() => {
setIsClient(true);
if (typeof window !== "undefined") {
setApiUrl(`https://${window.ip}:443`);
}
}, []);
/* if (!isClient) {
return null; // or a loading spinner
}*/
// Load the external JavaScript file and fetch the isolation values
useEffect(() => {
if (window.kueIso && Array.isArray(window.kueIso)) {