I'm trying to serve static files in a directory named "public" at the root of the project,
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'public')
}),
TypeOrmModule.forRoot(ormConfig),
TypeOrmModule.forFeature([Page, Setting]),
PagesModule,
SettingsModule
],
controllers: [AppController, PublicPagesController, AdminController],
providers: [AppService, PublicPagesService, SettingsService]
})
export class AppModule {}
code for the catchall
@Controller()
export class PublicPagesController {
constructor (private readonly publicPagesService: PublicPagesService) {}
@Get('*')
async catchAll (@Req() request: Request): Promise<string> {
the catch all is in the PublicPagesController, since I'm importing the ServeStatic at the top, if I had a "test.png" in the "public" directory, I should see the file if I accessed "http://localhost:3000/test.png", but when I access it I am hitting the catchall in the controller. Is there any reason this is happening?