Serving app with Client-Side Routing in NestJs

Viewed 12

I have a sample react app using react-router-dom with one route "/reset/:token"

when I run my app in development server and navigate to my route everything works fine

but in server static using ServeStaticModule when I navigate to my route I get "Cannot GET /reset/5T4665" and 404 status code

Here is my code:

App.module

    @Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: 'config/' + `.${process.env.NODE_ENV}.env`,
      isGlobal: true,
    }),
    MongooseModule.forRoot(`${process.env.MONGO_URI}`),
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'public'),
      renderPath: '/',
    }),
    BullModule.forRoot({
      redis: {
        host: 'localhost',
        port: 6379,
      },
    }),
  
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Any helps would be appreciated

1 Answers
Related