修改nginx配置文件解决纯前端调用接口的跨域问题

  • 内容
  • 评论
  • 相关
   add_header 'Access-Control-Allow-Origin' '*'; # 允许所有来源的请求
   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # 允许的方法
   add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; # 允许的请求头


增加位置如上图:

1111.png

本文标签:

版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。

本文链接:修改nginx配置文件解决纯前端调用接口的跨域问题 - http://wziyi.com.cn/?post=426

发表评论

电子邮件地址不会被公开。 必填项已用*标注