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 即可实现同域下请求
来源: https://www.2cto.com/kf/201802/722807.html