Last active
April 30, 2023 16:49
-
-
Save fhferreira/dfcd5c56dd9599abf75b to your computer and use it in GitHub Desktop.
Try to create - Cors Filter Laravel 5 Middleware
This file contains 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; | |
use Illuminate\Contracts\Routing\Middleware; | |
use Illuminate\Http\Response; | |
class CORS implements Middleware { | |
/** | |
* 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', 'POST, GET, OPTIONS, PUT, DELETE') | |
->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1