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 => {