Skip to content

Instantly share code, notes, and snippets.

@mohitmamoria
Created March 29, 2014 20:36
Show Gist options
  • Save mohitmamoria/9862447 to your computer and use it in GitHub Desktop.
Save mohitmamoria/9862447 to your computer and use it in GitHub Desktop.
Laravel OPTIONS filter
App::before(function($request)
{
if($request->server('REQUEST_METHOD') == 'OPTIONS')
{
$response = Response::make(null, 200);
$response->headers->set('Access-Control-Allow-Origin', Config::get('app.url'));
$response->headers->set('Access-Control-Allow-Methods', 'PUT, POST, GET, PATCH, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
return $response;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment