Skip to content

fix: Global middlewares are not used if route prefix doesn't start with a slash ("/") #1298

Open
@michaelseibt

Description

@michaelseibt

Description

Introducing route prefix scoping for global middlewares created a convention that config.routePrefix needs to start with a slash ("/"), otherwise global middlewares will not be applied.

Let's assume an application is defined as following:

useExpressServer(application, {
routePrefix: 'app',
controllers: [...],
middlewares: [AppMiddleware1, AppMiddleware2]
});

When doing so, none of the middlewares are executed globally for any possible route.

If the routePrefix is having a leading slash, this would work properly:

useExpressServer(application, {
routePrefix: '/app', // <---
controllers: [...],
middlewares: [AppMiddleware1, AppMiddleware2]
});

Expected behavior

Values of routePrefix are either rejected with an error if they don't start with a slash, or the ExpressDriver normalizes this and adds the slash if needed.

Actual behavior

Global middlewares are not used (registered, but use is not called) at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions