更新时间:2022-11-12 10:47:20
Laravel使用标头来确定请求是XHR还是常规请求.
Laravel uses a header to be able to determine wether a request was XHR or a normal request.
在Laravel的源代码中,您可以看到 Symfony中的 isXmlHttpRequest()
方法.
In the source code of Laravel you can see the Request::ajax()
method, which calls the isXmlHttpRequest()
method from Symfony.
唯一的问题是,CORS并不真的喜欢这样的标头.
The only issue with this is that CORS doesn't really like such headers.
如果要删除它,请检查 resources/js
中的 bootstrap.js
并再次编译资产.
If you want to remove it, check bootstrap.js
in resources/js
and compile your assets again.
另一种解决方案是在调用之前删除标头:
Another solution would be to delete the header just before the call:
删除axios.defaults.headers.common ['X-Requested-With'];
Axios返回请求标头字段X-Requested-With是Access-Control-Allow-Headers不允许的
IBM Watson Conversation API:“在飞行前响应中,Access-Control-Allow-Headers不允许请求标头字段授权”
Firebase-在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段x-firebase-gmpid
传入Webhook松弛:在飞行前响应中,Access-Control-Allow-Headers不允许请求标头字段Content-type
尽管有效的CORS配置,“在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段Access-Control-Allow-Origin"
通过SAM创建API时,在飞行前响应中Access-Control-Allow-Headers不允许请求标头字段的内容类型
飞行前响应中Access-Control-Allow-Headers不允许请求标头字段Access-Control-Allow-Methods