Laravel 中不允许 'Access-Control-Allow-Origin' header

Allow No 'Access-Control-Allow-Origin' header in Laravel

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

哦,知道了。我只需要在我的应用程序之前添加过滤器。

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