nginx解决前端跨域配置

在nginx.conf文件中 添加如上配置:

  nginx解决前端跨域配置

在ajax中将原来的 url:http://192.168.1.127:8905/findItem 改成:'http://localhost/findItem'

 

  listen :80;  #监听host为localhost:80 的客户端请求

  server_name localhost;

  # pathname 为 /findItem 时 设置请求 http://192.168.1.127:8905/findItem

  location /findItem {
    add_header 'Access-Control-Allow-Origin' '*';
    proxy_pass http://192.168.1.127:8905/findItem;
  }

相关文章:

  • 2021-05-03
  • 2020-04-26
  • 2021-11-01
  • 2021-12-29
  • 2021-10-31
  • 2021-07-02
  • 2022-01-06
  • 2021-08-18
猜你喜欢
  • 2021-12-04
  • 2021-08-17
  • 2019-01-15
  • 2021-04-09
  • 2021-01-10
  • 2021-11-28
  • 2018-02-03
  • 2020-07-20
相关资源
相似解决方案