Skip to content

Instantly share code, notes, and snippets.

@IonutBajescu
Last active August 14, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IonutBajescu/189b0314892244038d53ab85af58ba39 to your computer and use it in GitHub Desktop.
Save IonutBajescu/189b0314892244038d53ab85af58ba39 to your computer and use it in GitHub Desktop.
CORS for Lumen
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class AjaxAccessControlMiddleware
{
public function handle(Request $request, Closure $next)
{
$response = $request->isMethod('options') ? new Response() : $next($request);
return $response
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Headers', 'X-XSRF-TOKEN');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment