您现在的位置:首页 >> 前端 >> 内容

用nginx解决webstorm内置server调用本地api的跨域问题

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

  核心提示:webstorm内置的server在调用部署在本地不同端口的api时会产生跨域问题,在开发时可以用nginx代理解决跨域问题。nginx.conf文件 server域中:listen 80;serve...

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即可实现同域下请求。

Tags:用N NG GI IN 
作者:网络 来源:qkzia123的博