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 · 2 comments

Comments

@igorivaniuk
Copy link

commented May 21, 2018

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

This comment has been minimized.

Copy link
Member

commented May 23, 2018

Thanks for reporting!

@kamilmysliwiec kamilmysliwiec added this to the 5.0.1 milestone May 23, 2018

@kamilmysliwiec kamilmysliwiec self-assigned this May 23, 2018

@kamilmysliwiec

This comment has been minimized.

Copy link
Member

commented May 25, 2018

Fixed in v5.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.