Exclude path does not work when I wrap it up into an Azure function. See ClientInfoModule snippet below.
exclude({ path :'validate', method : RequestMethod.POST })
Even though the validate is specified in the exclude, the middleware is still called for that route.
Am I missing something trivial here ?
I followed the documentation here : https://docs.nestjs.com/middleware#functional-middleware
Here is a top level snippet of my code below.
import { Injectable, NestMiddleware } from '@nestjs/common';
export class AuthMiddleware implements NestMiddleware {
...
}
----------
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
export class ClientInfoModule implements NestModule{
configure(consumer: MiddlewareConsumer) {
consumer
.apply(AuthMiddleware)
.exclude(
{ path :'validate', method : RequestMethod.POST },
)
.forRoutes(ClientController, SomeOtherController);
}
}
----------
@Controller('validate')
export class ClientController {
constructor( ) {}
@Post()
async validateFingerprint(@Body() clientPayload: ClientPayload): Promise<ApiResponse>
{
... this should be excluded from the middleware
}
}