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后就跨域了,請(qǐng)求這個(gè)如何解決的
問題解決了
方便和我一樣的人不知道錯(cuò)誤,這里說下答案,如果你header傳了token,'Access-Control-Allow-Headers' => 'Content-Type,Authorization,X-Requested-With,Accept,Origin,requesttype', 這里需要增加一個(gè)token,例子里加了Authorization其實(shí)是參數(shù)傳這個(gè)Authorization就好了