Skip to content

ng serve with esbuild fails to serve directory assets #27044

Closed
@georgmu

Description

@georgmu

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

I have a setup with a non-angular login page, served at path /login/. This is included via assets in angular.json:

...
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/login"
            ],
...

When using ng serve with @angular-devkit/build-angular:browser and calling curl http://localhost:4200/login/, the login page is returned.

When using ng serve with @angular-devkit/build-angular:browser-esbuild or @angular-devkit/build-angular:application and calling curl http://localhost:4200/login/, the index.html of the angular project is returned.

The application redirects to /login/ if authentication is missing. This results in a redirect loop from / to /login (because angular router does not know about any /login/ route).

A work-around is to redirect directly to the index.html page ( curl http://localhost:4200/login/index.html works with both esbuild and the old setup), but this is looks a bit ugly.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.1.2
Node: 20.10.0
Package Manager: npm 10.4.0
OS: linux x64

Angular: 17.1.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, platform-browser
... platform-browser-dynamic, router

Anything else?

No response

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