Skip to content

Commit

Permalink
mas cabeceras cors & 200 para OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyfpmislata committed Feb 3, 2019
1 parent 63f21c7 commit b1b3080
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
ini_set('display_errors', 1);
$config = require_once "./configs/config.php";

// CORS: permitir acceso desde otros dominios
header('Access-Control-Allow-Origin: *');
// CORS: permitir más métodos aparte de los permitidos en "simple request"
header('Access-Control-Allow-Methods: *');
// CORS: permitir cookies
header('Access-Control-Allow-Credentials: true');

// CORS: devolver 200 (y no seguir con el enrutamiento) para peticiones OPTIONS
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit();
}

try {
$mysql = new PDO(
Expand Down

0 comments on commit b1b3080

Please sign in to comment.