Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel CORS Middleware
<?php
namespace App\Http\Middleware;
use Closure;
class CorsHeaders
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment