Skip to content

Instantly share code, notes, and snippets.

@stoll
Created June 12, 2017 13:22
Show Gist options
  • Save stoll/654d79d43941f48fc7b9b485047638cc to your computer and use it in GitHub Desktop.
Save stoll/654d79d43941f48fc7b9b485047638cc to your computer and use it in GitHub Desktop.
Cors middleware
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* 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, PUT, DELETE, OPTIONS');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment