Files
drivetimeplaner/www/fahrschultermin.de/public/index.php
Hermes Agent 2d6c0ad3aa Split API and frontend, migrate SQLite to PostgreSQL
- api.fahrschultermin.de: full API entry point with CORS + session auth
- fahrschultermin.de: frontend only, no more /api/v1 routing
- Database.php: PostgreSQL support (pgsql driver + lastval())
- All repositories: use Database::lastInsertId() for PG compatibility
- config/app.php: PostgreSQL connection settings + CORS config
- bootstrap.php: pass full $config to Database::configure()
- public/index.php: fetch-patch to redirect /api/v1 to api.fahrschultermin.de
- database/schema_pgsql.sql: full PostgreSQL schema (BIGSERIAL)
- database/import_pgsql.sql: 518 rows migrated from SQLite
2026-05-18 23:50:00 +02:00

53 lines
1.8 KiB
PHP

<?php
/**
* fahrschultermin.de — Frontend entry point
* Patches fetch() to proxy /api/v1/* calls to api.fahrschultermin.de
* so the JS bundle (with hardcoded /api/v1 paths) just works.
*/
const API_BASE = 'https://api.fahrschultermin.de';
$assetManifestPath = __DIR__ . '/assets/.vite/manifest.json';
$mainAsset = '/assets/index.js';
$styleAsset = '/assets/index.css';
if (is_file($assetManifestPath)) {
$manifest = json_decode(file_get_contents($assetManifestPath), true);
$entry = $manifest['src/main.jsx'] ?? null;
if (is_array($entry)) {
$mainAsset = '/assets/' . ltrim((string) $entry['file'], '/');
if (!empty($entry['css'][0])) {
$styleAsset = '/assets/' . ltrim((string) $entry['css'][0], '/');
}
}
}
?><!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DriveTime Planner</title>
<link rel="stylesheet" href="<?= htmlspecialchars($styleAsset, ENT_QUOTES) ?>">
</head>
<body>
<div id="root"></div>
<script>
// Patch fetch to redirect /api/v1/* → api.fahrschultermin.de/api/v1/*
window.__API_BASE__ = '<?= API_BASE ?>';
const _fetch = window.fetch.bind(window);
window.fetch = function (resource, options = {}) {
let url = typeof resource === 'string' ? resource : resource.url;
if (typeof url === 'string' && url.startsWith('/api/v1')) {
url = '<?= API_BASE ?>' + url;
const req = new Request(url, options);
req.credentials = 'include';
return _fetch(req);
}
return _fetch(resource, options);
};
</script>
<script type="module" src="<?= htmlspecialchars($mainAsset, ENT_QUOTES) ?>"></script>
</body>
</html>