I have developed an angular 7 app with express backend. Express running on localhost:3000 and angular client is running on localhost:4200.
In the
To divert all calls for http://localhost:4200/api to a server running on http://localhost:3000/api, take the following steps.
Create a file proxy.conf.json in the projects src/ folder, next to package.json.
Add the following content to the new proxy file:
{
"/api": {
"target": "`http://localhost:3000`",
"secure": false
}
}
...
"architect": {
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "your-application-name:build",
"proxyConfig": "src/proxy.conf.json"
},
...
}
}
...
ng serve.