During development, you often end up in the situation where you have your backend API server running at one address (i.e. localhost:8080) while your frontend development server runs on another (i.e. localhost:4200).
First create proxy.config.json file
Then serve your app with proxy option by type this command:
ng serve –proxy-config proxy.config.json
ref: Angular CLI commands reference: https://github.com/feloy/angular-cli-refcard/blob/master/angular-cli-refcard.pdf
If you work behind a corporate proxy, the regular backend proxy configuration will not work if you try to proxy calls to any URL outside your local network.
In this case, you can configure the backend proxy to redirect calls through your corporate proxy using an agent:
npm install --save-dev https-proxy-agent
Then instead of using a
proxy.conf.json file, we create a file called
proxy.conf.js with the content