站内搜索:
首页 >> 前端 >> 内容
用nginx解决webstorm内置server调用本地api的跨域问题

时间:2018/2/22 14:52:54

webstorm内置的server在调用部署在本地不同端口的api时会产生跨域问题,在开发时可以用nginx代理解决跨域问题。

nginx.conf文件 server域中:

listen 80;server_name localhost;root C:\Users\Administrator\Desktop\design;index index.html index.htm index.php;location /gP {????proxy_pass https://localhost:8080/gP;}

主要配置好root path和代理路径。

前端的请求url改为'/gP'+requestPath即可实现同域下请求。

  • 上一篇:Type of the default value for 'data' prop must be a function错误解决
  • 下一篇:html开发中CSS块格式化上下文实现方法
  • 返回顶部