php后端接口无法跨域

已经在php接口文件中添加:

header("Access-Control-Allow-Origin:*");
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');

然而前端调用接口请求数据时仍然报错:

Failed to load http://aaa.com/version?test=1: Redirect from 'http://aaa.com/version?test=1' to 'http://bbb.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ccc.com' is therefore not allowed access.

clipboard.png

clipboard.png

阅读 1.9k
评论
    3 个回答

    你可以使用callback的方式去解决前端的跨域问题

      相似问题
      推荐文章