CORS无法处理post请求

CORS无法处理post请求,cors,vue.js,laravel-5.3,Cors,Vue.js,Laravel 5.3,我有一块Vue.js: ... this.$http.post('http://localhost:8000/oauth/token', postData) .then(response => { console.log(response) }) this.$http.get('http://localhost:8000/api/test') .then(response => { console.log(response) }) ... 最后一个get请求

我有一块Vue.js:

...
this.$http.post('http://localhost:8000/oauth/token', postData)
  .then(response => {
    console.log(response)
})
this.$http.get('http://localhost:8000/api/test')
  .then(response => {
    console.log(response)
})
...
最后一个get请求工作正常,但由于

无法加载XMLHttpRequest。对飞行前请求的响应未通过访问控制检查:请求的资源上不存在“访问控制允许来源”标头。起源

My Cors.php中间件:

...
public function handle($request, Closure $next)
{
    return $next($request)
        ->header('Access-Control-Allow-Origin', '*')
        ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
}
...
Kernel.php:

...

    'api' => [
        'throttle:60,1',
        'bindings',
        \App\Http\Middleware\Cors::class,
    ],
...
我已经完成了php artisan route:list我注意到route
…oauth/token
具有中间件
throttle
,它是默认情况下唯一的一个。。。我在跟踪

这两个(客户端/服务器)都在本地主机上运行

假设您正在使用vue资源,请尝试在devtools的“网络”选项卡中调试您的调用


如果请求标头选项卡中没有CORS标头,请将此行放在
Vue.use(VueResource)
Vue.http.options.crossOrigin=true

尝试将中间件注册到web中间件组中,而不是api中one@El_Matella,则两个请求失败。我做了一个
php artisan路由:list
,这个路由只有中间件是
throttle
,如果你在全局注册它?如果我在
protected$middleware上注册了
protected$middleware
,问题仍然存在,如果你添加:
header('Access-Control-Allow-Headers',Origin,Content Type,X-Auth-Token')