Last updated Apr 13, 2021

How to Setting Up Proxy Configuration in Angular 14

In this tutorial, we will learn about How to Setting Up Proxy Configuration in Angular 14

How to Setting Up Proxy Configuration in Angular 14

In this tutorial, we will learn about How to Setting Up Proxy Configuration in Angular 12,13, or 14 versions.

What is a Proxy?

  Basically, Proxy configuration is a way of diverting specific URLs to a backend server.  

Also read, 5 Reasons Angular Is The Next Big Thing In Web Development

Set up Proxy Configuration in Angular step by step:

Step 1: Create a proxy config file

Create a new src/proxy.conf.json file and add the following configurations:

{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false
  }
}

Other proxy.config.json options:

target: Here is where the backend URL needs to be specified.

pathRewrite: This option is used to change or rewrite the path.

changeOrigin: We should set this value to true if your backend API is not accessible via localhost.

logLevel: If you want to make sure the proxy configuration is functioning properly use this.

Step 2: Update CLI configuration

 Go to angular.json and place the proxyConfig property to point towards the serve target as below:

........
........
"architect": {
  "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
      "browserTarget": "angular-application-name:build",
      "proxyConfig": "src/proxy.conf.json"
    },
.........
..........

Now You can test the dev server through the proxy configuration  which we have added in our angular application using the ng serve command

Tags

Available for projectsLet’s build together

Need this built properly,
not just explained?

I take on Angular and NestJS work directly — auth systems, multi-tenant SaaS, API rewrites and the deploy pipeline underneath them. You talk to the person writing the code.

Projects delivered
20+ Projects delivered
Angular • NestJS
7+ years Angular • NestJS
Average reply time
1 day Average reply time

What I can help with

  • Auth and permissions systems
  • Multi-tenant SaaS foundations
  • API design and rewrites
  • Deploy pipelines and VPS setup
  • Bug fixing and performance optimization
Send me a message

Tell me about your project and I’ll get back with a realistic scope and price.

Turn
Your Ideas
Into Reality

Stay in the loop

Get the finished tutorials, projects and resources in your inbox.

Join 5,000+ developers and get new tutorials, source code, product updates and exclusive content — straight to your inbox.

  • No spam
  • Useful content only
  • Unsubscribe anytime

Subscribe to TutsCoder

Be the first to get new tutorials, projects and tips.

Join 5,000+ developers already learning with us.

Learn
Build
Grow

Discussion

Comments

Share your thoughts, ask questions or suggest improvements. Let’s learn and grow together!

Loading comments…

Join the discussion

Sign in to join the discussion. Your account also keeps your saved tutorials and path progress.