Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wxingheng/a63f4a3670ee8d0cca814e53590569e0 to your computer and use it in GitHub Desktop.
Save wxingheng/a63f4a3670ee8d0cca814e53590569e0 to your computer and use it in GitHub Desktop.
基于angular-cli配置代理解决跨域请求问题 angular proxy
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