开启了\think\middleware\AllowCrossDomain::class中间件 还是报Access to xm
lHttpRequest at 'http://new.media.com/api/v1/payment' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 错误 在控制器加上header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:POST,GET');
// 响应头设置
header('Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept');
header("Access-Control-Allow-Credentials", true);就不会报跨域的问题。
不明白是什么原因