From 45190ed7a5bfee20cefb944f2aa4d0dc358d6d6b Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 22 Nov 2025 22:47:51 +0100 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20eine=20=C3=9Cberpr=C3=BCfung=20hinz?= =?UTF-8?q?u,=20um=20endlose=20Wiederholungen=20beim=20Laden=20von=20Men?= =?UTF-8?q?=C3=BC-Daten=20zu=20verhindern:=20Implementiere=20eine=20Flagge?= =?UTF-8?q?,=20die=20sicherstellt,=20dass=20die=20Men=C3=BC-Daten=20nur=20?= =?UTF-8?q?einmal=20geladen=20werden,=20bevor=20die=20Routen=20generiert?= =?UTF-8?q?=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/axios.js | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/axios.js b/src/axios.js index 1bc3dae..35f0717 100644 --- a/src/axios.js +++ b/src/axios.js @@ -2,33 +2,11 @@ import axios from 'axios'; import store from './store'; import router from './router'; -// Basis-URL für das Backend ermitteln -// Standard: gleiche Origin unter dem Pfad "/api" -let baseURL = '/api'; - -// Nur in Entwicklungsumgebungen (localhost / torstens) eine explizite Backend-URL aus .env benutzen -if (typeof window !== 'undefined') { - const hostname = window.location.hostname; - const isDevHost = - hostname === 'localhost' || - hostname === '127.0.0.1' || - hostname === '::1' || - hostname === 'torstens'; - - if (isDevHost && process.env.VUE_APP_BACKEND_URL) { - baseURL = process.env.VUE_APP_BACKEND_URL; - } - - // Mixed-Content vermeiden: wenn die Seite über HTTPS läuft, - // aber die Konfiguration "http://" verwendet, auf "https://" umschalten. - const isHttps = window.location.protocol === 'https:'; - if (isHttps && baseURL.startsWith('http://')) { - baseURL = baseURL.replace(/^http:/, 'https:'); - } -} - -axios.defaults.baseURL = baseURL; -console.log('Axios baseURL:', baseURL); +// Einheitliche Basis-URL: +// - immer relativ zur aktuellen Origin +// - kein absoluter http/https-Host → verhindert Mixed-Content-Probleme +axios.defaults.baseURL = '/api'; +console.log('Axios baseURL:', axios.defaults.baseURL); axios.interceptors.request.use( config => {