ThinkPHP3 解决前后端分离项目跨域问题
文章目录
/*
** @author water
** @admin 跨域问题
** @2018-10-10
**
*/
public function _initialize(){
$this->cross();
}
public function cross(){
header('Content-Type:application/json; charset=utf-8');
header('Access-Control-Allow-Origin:前端域名地址');
//header('Access-Control-Max-Age:86400');
header('Access-Control-Allow-Methods:OPTIONS,POST,PUT,DELETE');
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论