Hello,
I recently upgraded NestJS to v11 with fastify.
I serve my react app with the @nestjs/serve-static package.
When I use the url http://localhost:3000 it shows me my app, but if I try to access it from a different url like http://localhost:3000/login it sends me a 404 not found error.
It was falling back to index.html prior upgrade.
It seems to no longer do it. I really don't know how to troubleshoot the issue.
I am not using any global prefix.
Here is my bootstrap:
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
app.enableShutdownHooks();
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transformOptions: {
exposeUnsetFields: false,
},
}),
);
await app.register(secureSession, {
secret: process.env.APPLICATION_SECRET,
salt: process.env.APPLICATION_SALT,
cookie: {
path: '/',
httpOnly: true,
maxAge: 365 * 24 * 60 * 60,
},
});
await app.listen(process.env.APPLICATION_PORT, '::');
}
Here is my AppModule:
@Module({
imports: [
ConfigModule.forRoot({
envFilePath: ['.env'],
isGlobal: true,
load: [configuration],
}),
ScheduleModule.forRoot(),
ServeStaticModule.forRoot({
rootPath: join(__dirname, '../public'),
}),
EventEmitterModule.forRoot(),
// Other custom modules below...
],
controllers: [],
})
export class AppModule {}
Versions
"@fastify/secure-session": "8.1.1",
"@fastify/static": "8.1.0",
"@nestjs/common": "11.0.8",
"@nestjs/config": "4.0.0",
"@nestjs/core": "11.0.8",
"@nestjs/cqrs": "11.0.1",
"@nestjs/event-emitter": "3.0.0",
"@nestjs/platform-fastify": "11.0.8",
"@nestjs/schedule": "5.0.1",
"@nestjs/serve-static": "5.0.2",