Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
michaelseibt opened this issue Dec 7, 2023 · 0 comments
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@michaelseibt
Copy link

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.

@michaelseibt michaelseibt added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

1 participant