使用nginx搭建PbootCMS项目中,因部分条件因素可能需要跨域,但会报错。解决办法在Nginx location里加上如下代码可以解决跨域问题:

在Nginx配置文件nginx.conf加入如下代码:

location/{#跨域设置
      add_header Access-Control-Allow-Origin*;
      add_header Access-Control-Allow-Methods'GET,POST,OPTIONS';
      add_header'Access-Control-Allow-Credentials''true';
      if($request_method='OPTIONS'){return 200;}
}