1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* V2-Plattform — Common-Bootstrap
|
|
*
|
|
* Wird von jedem API-Endpoint includiert.
|
|
* Setzt Error-Handling, lädt Config + Lib, setzt JSON-Header.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
// Strict Errors für Entwicklung — auf Prod ggf. abschalten
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', '1');
|
|
|
|
require_once __DIR__ . '/config.php';
|
|
require_once __DIR__ . '/lib/db.php';
|
|
require_once __DIR__ . '/lib/auth.php';
|
|
require_once __DIR__ . '/lib/response.php';
|
|
require_once __DIR__ . '/lib/validation.php';
|
|
|
|
// JSON-Default für API-Endpoints
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
// CORS — gleiche Origin im Normalfall, Pre-Flight zulassen
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
|
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
|
|
if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') {
|
|
http_response_code(204);
|
|
exit;
|
|
}
|
|
|
|
// Globaler Exception-Handler — alles als JSON
|
|
set_exception_handler(function (Throwable $e) {
|
|
error_log('[V2 Uncaught] ' . $e->getMessage() . "\n" . $e->getTraceAsString());
|
|
if (!headers_sent()) {
|
|
http_response_code(500);
|
|
}
|
|
echo json_encode([
|
|
'error' => 'internal_server_error',
|
|
'message' => $e->getMessage(),
|
|
], JSON_UNESCAPED_UNICODE);
|
|
exit;
|
|
});
|