1
0

Развитие бека

1. Создание БД
2. Создание бека
3. Пока создали класс юзера
This commit is contained in:
2026-01-11 17:48:05 +07:00
parent 301e179160
commit a9c146b192
9 changed files with 351 additions and 15 deletions

View File

@@ -2,6 +2,19 @@
require_once __DIR__ . '/app/config.php';
// CORS заголовки
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
header("Access-Control-Allow-Origin: $origin");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
// Preflight запрос
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
// Игнорируем запросы к favicon.ico и другим статическим файлам
$requestUri = $_SERVER['REQUEST_URI'] ?? '';
if (preg_match('/\.(ico|png|jpg|jpeg|gif|css|js|svg|woff|woff2|ttf|eot)$/i', $requestUri)) {
@@ -9,8 +22,7 @@ if (preg_match('/\.(ico|png|jpg|jpeg|gif|css|js|svg|woff|woff2|ttf|eot)$/i', $re
exit;
}
header('Content-Type: application/json; charset=utf-8');
$accounts = Database::select('accounts', '*');
handleRouting($routes);
echo json_encode([$accounts]);
?>