PHP处理前端API接口跨域名

 在API返回前加入下面三行。  

header("Access-Control-Allow-Origin:*");    //允许访问的来源域名
header('Access-Control-Allow-Methods:POST');    //响应类型: post,get等 允许的请求方式
header('Access-Control-Allow-Headers:x-requested-with, content-type');    //响应头设置

  

posted @ 2020-08-19 15:02  智昕  阅读(364)  评论(0)    收藏  举报