【发布时间】:2020-01-05 22:07:02
【问题描述】:
我已经为 localhost:5000 中的服务配置了 api 调用代理。 但是,代理被定向到 localhost:4200 。即角度应用程序。 "http://localhost:4200/api/ 的 Http 失败响应:404 Not Found"
我的 proxy.conf.json:
{
"/api": {
"target": "https://127.0.0.1:5000/",
"secure": false,
"changeOrigin": true
}
}
我对服务中 url 的调用:
private apiurl = "/api";
constructor(private http: HttpClient) { }
getData() {
return this.http.get(this.apiurl);
}
我在 package.json 中编辑了“开始”
"start": "ng serve --proxy-config proxy.conf.json",
我没有收到任何编译错误。
我希望 /api 转到代理 conf 文件中提供的目标
【问题讨论】: