我怎样才能允许laravel No 'Access-Control-Allow-Origin' header is present on the requested
?因为当我尝试使用angular.js $http.get()
某个网址时,我总是会遇到错误。
答案 0 :(得分:6)
哦,明白了。我只需要在我的应用程序上过滤之前添加。
<强> filters.php 强>
App::before(function($request)
{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Requested-With');
header('Access-Control-Allow-Credentials: true');
});