EDIT: THIS NO LONGER WORKS IN CURRENT ANGULAR-CLI
See answer from @imal hasaranga pereraother answers for up-to-date solution
The server in angular-cli
comes from the ember-cli
project. To configure the server, create an .ember-cli
file in the project root. Add your JSON config in there:
{
"proxy": "https://api.example.com"
}
Restart the server and it will proxy all requests there.
For example, I'm making relative requests in my code to /v1/foo/123
, which is being picked up at https://api.example.com/v1/foo/123
.
You can also use a flag when you start the server:
ng serve --proxy https://api.example.com
Current for angular-cli version: 1.0.0-beta.0