From 550ed97a11515c49db5f6f832f358e97b571e090 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 22 Nov 2025 22:23:08 +0100 Subject: [PATCH] =?UTF-8?q?Aktualisiere=20die=20Axios-Konfiguration:=20Set?= =?UTF-8?q?ze=20die=20Basis-URL=20standardm=C3=A4=C3=9Fig=20auf=20'/api'?= =?UTF-8?q?=20und=20erm=C3=B6gliche=20die=20Verwendung=20einer=20Umgebungs?= =?UTF-8?q?variablen=20in=20Entwicklungsumgebungen.=20Verhindere=20Mixed-C?= =?UTF-8?q?ontent-Probleme=20durch=20Umstellung=20auf=20HTTPS.=20=C3=84nde?= =?UTF-8?q?re=20den=20Import=20von=20Axios=20im=20Store,=20um=20die=20neue?= =?UTF-8?q?=20Konfiguration=20zu=20nutzen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/axios.js | 19 ++++++++++++++++--- src/store/index.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/axios.js b/src/axios.js index cad0540..1bc3dae 100644 --- a/src/axios.js +++ b/src/axios.js @@ -3,11 +3,24 @@ import store from './store'; import router from './router'; // Basis-URL für das Backend ermitteln -let baseURL = process.env.VUE_APP_BACKEND_URL || '/api'; +// Standard: gleiche Origin unter dem Pfad "/api" +let baseURL = '/api'; -// Mixed-Content vermeiden: wenn die Seite über HTTPS läuft, -// aber die Konfiguration "http://" verwendet, auf "https://" umschalten. +// 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:'); diff --git a/src/store/index.js b/src/store/index.js index c81ecc5..9bf4ce3 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,5 +1,5 @@ import { createStore } from 'vuex'; -import axios from 'axios'; +import axios from '../axios'; import router from '../router'; let user = [];