Last active
August 7, 2018 06:15
-
-
Save wxingheng/a63f4a3670ee8d0cca814e53590569e0 to your computer and use it in GitHub Desktop.
基于angular-cli配置代理解决跨域请求问题
angular proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.首先我们创建代理配置文件proxy.conf.json | |
假如你的后端服务的访问地址为“10.4.60.200:8080”,以下为proxy.conf.json的例子; | |
```language | |
{ | |
"/api": { | |
"target": "http://10.4.60.200:8080", | |
"secure": false | |
} | |
} | |
``` | |
2.改写package.json | |
```language | |
"start": "ng serve --proxy-config proxy.conf.json", | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment