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(JwtMiddleware).forRoutes(AppController) with setGlobalPrefix dont work #718

Closed
igorivaniuk opened this issue May 21, 2018 · 3 comments

Comments

@igorivaniuk
Copy link

I'm submitting a...


[x] Regression 
[ ] 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

when set app.setGlobalPrefix('api')

@Module({
  imports: [],
  controllers: [AppController],
  providers: [ AppService ]
})
export class AppModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(JwtMiddleware).forRoutes(AppController); // not work
    consumer.apply(FooMiddleware).forRoutes('/home'); // not work
    consumer.apply(BarMiddleware).forRoutes('/api/home'); // work
  }
}

app.controller.ts

@Controller('home')
export class AppController {
  constructor() {}
  @Get()
  root(@Req() req: any): any {
    return {
      foo: req.foo,
      bar: req.bar,
      jwt: req.jwt,
    };
  }
}

Expected behavior

consumer.apply(JwtMiddleware).forRoutes(AppController); // work
consumer.apply(FooMiddleware).forRoutes('/home'); // work
consumer.apply(BarMiddleware).forRoutes('/api/home'); // work

Minimal reproduction of the problem with instructions

https://github.com/igorivaniuk/nest-prefix-bug

What is the motivation / use case for changing the behavior?

Environment


Nest version: v8.9.4


Nest: 5.0.0 

For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@kamilmysliwiec
Copy link
Member

Thanks for reporting!

@kamilmysliwiec
Copy link
Member

Fixed in v5.0.1

@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

2 participants