Skip to content

Instantly share code, notes, and snippets.

@vaporic
Last active March 22, 2021 11:26
Show Gist options
  • Save vaporic/b1d68d3ee658e9383e8560b4ff3ef12b to your computer and use it in GitHub Desktop.
Save vaporic/b1d68d3ee658e9383e8560b4ff3ef12b to your computer and use it in GitHub Desktop.
CORS Laravel 5.1

Activar CORS Laravel 5.1

Para activar los CORS se edita el archivo /bootstrap/app.php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Credentials: true');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
   header( "HTTP/1.1 200 OK" );
   exit();
}

(opcional) deshabilitar VerifyCsrfToken desde el archivo /app/Http/Kernel.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment