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
Try the following things, mostly it will be either of these:
Add the following:
"changeOrigin": true,
"pathRewrite": {"^/service" : ""}
Run
ng serve --proxy-config proxy.config.json
this work for me proxy.config.json file
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"changeOrigin": true
}
}
and add "ng serve --proxy-config proxy.config.json" in package.json and run command npm start
Please follow below steps
1 In Angular project create a file called **proxy.cons.json** with content like this:
{
"/api/*": {
"target": "http://127.0.0.1:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
2 edit package.json file and add below code
"start": "ng serve --proxy-config proxy.conf.json"
3 call your backend api like this
this.http.get('/api/v1/people')
.map(res => res.json());
4 run npm start or ng serve --proxy-config proxy.conf.json