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

consumer.apply(middleware).forRoutes(pathString) not working #692

Closed
bojidaryovchev opened this issue May 16, 2018 · 6 comments
Closed

consumer.apply(middleware).forRoutes(pathString) not working #692

bojidaryovchev opened this issue May 16, 2018 · 6 comments

Comments

@bojidaryovchev
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

in the .module - consumer.apply([middlewares]).forRoutes('get/stuff');

At the moment, the middlewares don't get invoked when we pass a single route as a string, it only works with a controller.. So we are unable to configure middlewares for a certain route..

Expected behavior

The middlewares should be called before the controller.

@kamilmysliwiec
Copy link
Member

Hey @bojidaryovchev,
Thanks for reporting, I'll take a look at it 👍

@kamilmysliwiec
Copy link
Member

Fixed in v5.0.1

@felangel
Copy link

felangel commented Mar 12, 2019

@kamilmysliwiec I'm seeing this issue again in v5.7.4. Middleware is invoked with a controller is passed but not when a string is passed.

This works:

export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(LoggerMiddleware).forRoutes(MyController);
  }
}

But this doesn't:

export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(LoggerMiddleware).forRoutes('*');
  }
}

@kamilmysliwiec
Copy link
Member

@felangel could you please create a separate issue? :)

@felangel
Copy link

@kamilmysliwiec thanks for the quick reply! I saw the issue was fixed in the latest release 👍🎉💯

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants