Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Only first rule is taken into account in proxy configuration #2411

@VictorienTardif

Description

@VictorienTardif

🐞 Bug report

What modules are related to this issue?

  • aspnetcore-engine
  • builders
  • common
  • express-engine
  • hapi-engine

Is this a regression?

I don't know.

Description

When you have several rules in your proxy configuration file only the first one is taken, following are ignored.

🔬 Minimal Reproduction

  1. Create a proxy.conf.json file with 2 rules
{
  "/api1": {
    "target": "http://www.api1.com",
    "pathRewrite": {
      "^/api1": "/"
    },
    "secure": false
  },
  "/api2": {
    "target": "http://www.api2.com",
    "pathRewrite": {
      "^/api2": "/"
    },
    "secure": false
  }
}
  1. Add the proxyConfig option in angular.json
"serve-ssr": {
       "builder": "@nguniversal/builders:ssr-dev-server",
        ...
       "options": {
         "proxyConfig": "proxy.conf.json"
       }
},
  1. Run the Angular Universal Live Development Server

Only the first rule is taken into account:

Compiled successfully.
[HPM] Proxy created: /api1 -> http://www.api1.com
[HPM] Proxy rewrite rule created: "^/api1" ~> "/"
** Angular Universal Live Development Server is listening on http://localhost:4200, open your browser on http://localhost:4200 **

🌍 Your Environment


Angular CLI: 12.2.4
Node: 14.15.0
Package Manager: yarn 1.22.11
OS: darwin x64

Angular: 12.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.8
@angular-devkit/build-angular   12.2.4
@angular-devkit/core            12.2.4
@angular-devkit/schematics      12.2.4
@angular/cdk                    12.2.6
@angular/fire                   7.0.4
@angular/flex-layout            12.0.0-beta.35
@nguniversal/builders           12.1.2
@nguniversal/express-engine     12.1.2
@schematics/angular             12.2.4
rxjs                            6.6.7
typescript                      4.3.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions