DEV Community

Leonel Elimpe
Leonel Elimpe

Posted on • Originally published at leonelngande.com on

Angular Tip: Hide Proxy Redirect CLI Command In angular.json

Wouldn’t it be great if instead of doing ng serve --proxy-config proxy.conf.js you simply use ng serve and the Angular CLI takes care of the proxy redirect command? Well, you can.

In the CLI configuration file, angular.json, add the proxyConfig option to the serve target:

...
"architect": {
  "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
      "browserTarget": "your-application-name:build",
      "proxyConfig": "src/proxy.conf.js"
    },
...
Enter fullscreen mode Exit fullscreen mode

Now we can call ng serve to run the dev server with this proxy configuration, neat 🙂.

You can read more on this in the Angular Docs, happy coding!

Top comments (0)