Created
March 7, 2019 20:32
-
-
Save nullthoughts/aeb137c84fd2687bc6bf449cf83b393c to your computer and use it in GitHub Desktop.
Laravel CORS Middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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