I have developed a simple application using AngularJS hosted here. I am consuming an API I developed myself in Laravel hosted here. When I try to log into the application us
in filters.php (Laravel 4.2)
add below
App::before(function($request)
{
// Enable CORS
// In production, replace * with http://yourdomain.com
header("Access-Control-Allow-Origin: *");
//header('Access-Control-Allow-Credentials: true'); optional
if (Request::getMethod() == "OPTIONS") {
// The client-side application can set only headers allowed in Access-Control-Allow-Headers
$headers = [
'Access-Control-Allow-Methods'=> '*',
'Access-Control-Allow-Headers'=> '*'
];
return Response::make('You are connected to the API', 200, $headers);
}
});
you can change the values of Access-Control-*
to suite your need