tp5跨域问题

header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, X-Token");
header("Access-Control-Allow-Methods:PUT,POST,GET,DELETE,OPTIONS");
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
    return true;
    exit();
    // 比如是跨域请求,客户端搜索a,第一次搜索时,会发生一次options请求。如果请求链接不变,则不会再次发起options请求
}

猜你喜欢

转载自www.cnblogs.com/xiondun/p/12552396.html
tp5