我正在尝试使用GraphQL在laravel上设置API,另一方面,我的前端基于Vuejs,当我尝试在本地调用API时,出现错误:
preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
在laravel一侧,我有一个网络路由,/带有我创建的中间件核心的graphql
//Cors.php
return ($next)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
}
您知道为什么身体无法激活吗?