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 http://localhost:8080/gP
;
}
主要配置好root path和代理路径。
前端的请求url改为'/gP'+requestPath即可实现同域下请求。