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;
  }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2021-06-01
  • 2022-01-03
  • 2022-12-23
  • 2021-12-04
  • 2021-08-17
相关资源
相似解决方案