Angular-CLI proxy to backend doesn't work

后端 未结 9 1123
不知归路
不知归路 2020-11-28 08:00

https://github.com/angular/angular-cli#proxy-to-backend here is an instruction how to do proxying to backend. I did everything step by step and still requests aren\'t proxie

9条回答
  •  臣服心动
    2020-11-28 08:27

    On MAC this works for me

    Angular 4 running localhost: http://localhost:4200/

    In package.json

    "start": "ng serve --proxy-config proxy.config.json",
    

    In proxy.config.json

    Where our-company-server would be replaced by off-site URL

    {
      "/v1": {
        "target": "https://our-company-server.com:7002",
        "secure": false,
        "logLevel": "debug"
      }
    }
    

    Where an angular GET request would be...

    this.http.get('/v1/dashboard/client', options).map...
    
    // options are headers, params, etc...
    // then .map the observable in this case.
    

提交回复
热议问题