ajax带header请求跨域问题 跑【webman】

good5tea

webman
中间件配置了
$response->withHeaders([
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS',
'Access-Control-Allow-Headers' => 'Content-Type,Authorization,X-Requested-With,Accept,Origin,requesttype',
]);
ajax如果不加header跨域是没问题的,加了header后就跨域了,请求这个如何解决的

问题解决了

方便和我一样的人不知道错误,这里说下答案,如果你header传了token,'Access-Control-Allow-Headers' => 'Content-Type,Authorization,X-Requested-With,Accept,Origin,requesttype', 这里需要增加一个token,例子里加了Authorization其实是参数传这个Authorization就好了

3219 0 0
0个回答

年代过于久远,无法发表回答
🔝