【问题标题】:angular8 proxy being directed to localhost:4200angular 8 代理被重定向到 localhost:4200
【发布时间】: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 文件中提供的目标

【问题讨论】:

    标签: proxy angular8


    【解决方案1】:

    非常抱歉这个问题,问题出在我的后端路由中

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-18
      • 2020-09-11
      • 2020-05-08
      相关资源
      最近更新 更多