Simplify to always run at domain root instead of dual /hifi vs / support
Statt Env-Var-gesteuertem Dualbetrieb (lokal /hifi, live /) läuft jetzt alles einheitlich unter der Domain-Wurzel - auch lokal (siehe neuer VirtualHost auf Port 8080 in der Apache-Konfiguration, unabhängig von Port 80 mit /hifi). Dabei einen Doppel-Slash-Bug in der Routenberechnung gefunden und behoben (base_path '/' + '/api' ergab faelschlich '//api'). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
618a32182c
commit
75684df837
6 changed files with 10 additions and 38 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -27,10 +27,6 @@
|
|||
# pro Umgebung unterschiedlich und darf nicht öffentlich einsehbar sein
|
||||
/hifi/api/config/setup.php
|
||||
|
||||
# Wird nur im IONOS-Deploy-Now-Build-Schritt geschrieben (Root-Domain statt /hifi),
|
||||
# lokal nicht vorhanden -> Fallback in config.php greift dann
|
||||
/hifi/api/config/base_path.php
|
||||
|
||||
# Claude-Code-Tooling (Skills/lokale Einstellungen) - gehört nicht zum Website-Projekt
|
||||
/hifi/.claude/
|
||||
/hifi/.agents/
|
||||
|
|
|
|||
|
|
@ -1,22 +1,17 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
// Lokal (XAMPP) läuft die Seite unter /hifi/, auf IONOS Deploy Now unter der
|
||||
// Domain-Wurzel. VITE_BASE_PATH wird nur im CI-Build-Schritt auf "/" gesetzt,
|
||||
// lokal bleibt der Default unverändert.
|
||||
const base = process.env.VITE_BASE_PATH || '/hifi/';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base,
|
||||
base: '/',
|
||||
build: {
|
||||
outDir: '../hifi',
|
||||
emptyOutDir: false,
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/hifi/api': {
|
||||
target: 'http://localhost',
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
# Für die lokale XAMPP-Entwicklung (Seite liegt unter /hifi/). Die Root-Domain-
|
||||
# Variante für den IONOS-Deploy-Now-Build liegt in .htaccess.ionos und wird dort
|
||||
# beim Bauen automatisch anstelle dieser Datei verwendet.
|
||||
RewriteEngine On
|
||||
RewriteBase /hifi/
|
||||
RewriteBase /
|
||||
|
||||
# API-Requests an den PHP-Front-Controller weiterleiten
|
||||
RewriteCond %{REQUEST_URI} ^/hifi/api/
|
||||
RewriteCond %{REQUEST_URI} ^/api/
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^api/(.*)$ api/public/index.php [QSA,L]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# API-Requests an den PHP-Front-Controller weiterleiten
|
||||
RewriteCond %{REQUEST_URI} ^/api/
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^api/(.*)$ api/public/index.php [QSA,L]
|
||||
|
||||
# Dynamische sitemap.xml (DB-generiert)
|
||||
RewriteRule ^sitemap\.xml$ api/public/sitemap.php [L]
|
||||
|
||||
# Alles andere: SPA-Fallback auf index.html (React Router übernimmt das Routing)
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.html [QSA,L]
|
||||
|
|
@ -24,10 +24,9 @@ return [
|
|||
'to_email' => 'kontakt@example.com',
|
||||
],
|
||||
'app' => [
|
||||
// Muss zum Vite "base" passen und wird für Session-Cookie-Pfad und Upload-URLs
|
||||
// genutzt. Lokal (XAMPP) ist das /hifi, im IONOS-Deploy-Now-Build wird beim
|
||||
// Bauen eine base_path.php mit '/' geschrieben (siehe .github Workflow).
|
||||
'base_path' => is_file(__DIR__ . '/base_path.php') ? require __DIR__ . '/base_path.php' : '/hifi',
|
||||
// Läuft überall (lokal wie live) unter der Domain-Wurzel. Muss zum Vite
|
||||
// "base" passen und wird für Session-Cookie-Pfad und Upload-URLs genutzt.
|
||||
'base_path' => '/',
|
||||
'session_name' => 'hifi_admin_session',
|
||||
// Öffentliche Domain der Seite (für sitemap.xml, robots.txt, Canonical-URLs). Ohne abschließenden Slash.
|
||||
'site_url' => 'https://hifi-planet.de',
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') {
|
|||
|
||||
session_name($config['app']['session_name']);
|
||||
session_set_cookie_params([
|
||||
'path' => $config['app']['base_path'] . '/',
|
||||
'path' => rtrim($config['app']['base_path'], '/') . '/',
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
|
|
@ -160,7 +160,7 @@ $router->post('/setup/migrate', fn($p) => SetupController::migrateSchema());
|
|||
$router->post('/setup/admin', fn($p) => SetupController::createAdmin());
|
||||
|
||||
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
$apiBase = $config['app']['base_path'] . '/api';
|
||||
$apiBase = rtrim($config['app']['base_path'], '/') . '/api';
|
||||
$route = '/' . ltrim(substr($path, strlen($apiBase)), '/');
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
|
|
|||
Loading…
Reference in a new issue