Actualiser api/auth.php

This commit is contained in:
2026-07-03 13:53:34 +02:00
parent c50029d479
commit 76cca33885
+7 -3
View File
@@ -1,14 +1,18 @@
<?php <?php
// Autoriser les requêtes depuis n'importe quelle origine // ==========================================
// 1. GESTION CORS (À METTRE TOUT EN HAUT)
// ==========================================
// Autoriser les requêtes depuis n'importe quelle origine (ou remplacez * par http://localhost)
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS"); header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With"); header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
// Répondre immédiatement aux requêtes preflight OPTIONS // Répondre immédiatement aux requêtes preflight OPTIONS du navigateur
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200); http_response_code(200);
exit(); exit(); // On arrête le script ici pour l'OPTIONS
} }
// ==========================================
require_once 'config.php'; require_once 'config.php';