允许否“访问控制 - 允许 - 来源”#39;在拉拉维尔头球

时间:2015-01-22 19:11:25

标签: php angularjs laravel nginx

我怎样才能允许laravel No 'Access-Control-Allow-Origin' header is present on the requested?因为当我尝试使用angular.js $http.get()某个网址时,我总是会遇到错误。

1 个答案:

答案 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');
});