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
|
# pro Umgebung unterschiedlich und darf nicht öffentlich einsehbar sein
|
||||||
/hifi/api/config/setup.php
|
/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
|
# Claude-Code-Tooling (Skills/lokale Einstellungen) - gehört nicht zum Website-Projekt
|
||||||
/hifi/.claude/
|
/hifi/.claude/
|
||||||
/hifi/.agents/
|
/hifi/.agents/
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,17 @@
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
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({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
base,
|
base: '/',
|
||||||
build: {
|
build: {
|
||||||
outDir: '../hifi',
|
outDir: '../hifi',
|
||||||
emptyOutDir: false,
|
emptyOutDir: false,
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/hifi/api': {
|
'/api': {
|
||||||
target: 'http://localhost',
|
target: 'http://localhost:8080',
|
||||||
changeOrigin: true,
|
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
|
RewriteEngine On
|
||||||
RewriteBase /hifi/
|
RewriteBase /
|
||||||
|
|
||||||
# API-Requests an den PHP-Front-Controller weiterleiten
|
# API-Requests an den PHP-Front-Controller weiterleiten
|
||||||
RewriteCond %{REQUEST_URI} ^/hifi/api/
|
RewriteCond %{REQUEST_URI} ^/api/
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^api/(.*)$ api/public/index.php [QSA,L]
|
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',
|
'to_email' => 'kontakt@example.com',
|
||||||
],
|
],
|
||||||
'app' => [
|
'app' => [
|
||||||
// Muss zum Vite "base" passen und wird für Session-Cookie-Pfad und Upload-URLs
|
// Läuft überall (lokal wie live) unter der Domain-Wurzel. Muss zum Vite
|
||||||
// genutzt. Lokal (XAMPP) ist das /hifi, im IONOS-Deploy-Now-Build wird beim
|
// "base" passen und wird für Session-Cookie-Pfad und Upload-URLs genutzt.
|
||||||
// Bauen eine base_path.php mit '/' geschrieben (siehe .github Workflow).
|
'base_path' => '/',
|
||||||
'base_path' => is_file(__DIR__ . '/base_path.php') ? require __DIR__ . '/base_path.php' : '/hifi',
|
|
||||||
'session_name' => 'hifi_admin_session',
|
'session_name' => 'hifi_admin_session',
|
||||||
// Öffentliche Domain der Seite (für sitemap.xml, robots.txt, Canonical-URLs). Ohne abschließenden Slash.
|
// Öffentliche Domain der Seite (für sitemap.xml, robots.txt, Canonical-URLs). Ohne abschließenden Slash.
|
||||||
'site_url' => 'https://hifi-planet.de',
|
'site_url' => 'https://hifi-planet.de',
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') {
|
||||||
|
|
||||||
session_name($config['app']['session_name']);
|
session_name($config['app']['session_name']);
|
||||||
session_set_cookie_params([
|
session_set_cookie_params([
|
||||||
'path' => $config['app']['base_path'] . '/',
|
'path' => rtrim($config['app']['base_path'], '/') . '/',
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => 'Lax',
|
'samesite' => 'Lax',
|
||||||
]);
|
]);
|
||||||
|
|
@ -160,7 +160,7 @@ $router->post('/setup/migrate', fn($p) => SetupController::migrateSchema());
|
||||||
$router->post('/setup/admin', fn($p) => SetupController::createAdmin());
|
$router->post('/setup/admin', fn($p) => SetupController::createAdmin());
|
||||||
|
|
||||||
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
$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)), '/');
|
$route = '/' . ltrim(substr($path, strlen($apiBase)), '/');
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue