Created
February 21, 2017 09:06
-
-
Save MahdiMajidzadeh/33ed8fc0a4ffe400a863bda599a3d855 to your computer and use it in GitHub Desktop.
fix Access-Control-Allow-Origin in laravel
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
public function handle($request, Closure $next) | |
{ | |
$domains = ['http://localhost:8080']; | |
if(isset($request->server()['HTTP_ORIGIN'])){ | |
$origin = $request->server()['HTTP_ORIGIN']; | |
if(in_array($origin, $domains)){ | |
header('Access-Control-Allow-Origin: '. $origin); | |
header('Access-Control-Allow-Headers: Origin, Content-type, Authorization'); | |
} | |
} | |
return $next($request); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment