Using the default express adapter works fine.
Code:
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { AppModule } from './app.module';
const bootstrap = async () => {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
await app.listen(3000, '0.0.0.0');
};
bootstrap().then().catch();
Simply removing FastifyAdapter
makes everything work fine again.
Tried removing node_modules
, cleairng cache etc.
Currently reverted to 5.7.4 where everything works fine with FastifyAdapter
I thought this was just me and a way I had my code set up. Initializing a new nest app with nest new fastify-test
and adding the fastify adapter doesn't seem to break it though, so far as I could tell.
I can reproduce this issue:
https://gist.github.com/BrunnerLivio/cd0bb683a73bfcb90d3c0ffd7dcac412
I also came across this issue and tried the proposed solution. However there is no any difference with 404 response. To reproduce the issue - I downloaded 6.0.0 archive from GitHub releases subpage and extracted the contents on my system. Then I moved to the samples/10-fastify
, commented out controller guard for cats and ran npm install
+ npm start
. I visited both http://localhost:3000/cats
and http://localhost:3000/cats/
in different browsers, with different/random sequence of entering URLs (first with trailing slash and after that without it). I'm still getting 404 and can't get the right answer with fastify - with express everything works as expected. I'm having the same problem with the endpoint which is specified for Swagger docs.
@truewt thanks. For some reason it seems that app starts working correctly when you simulate the first HTTP request:
await app.listen(3000);
await app
.getHttpAdapter()
.getInstance()
.inject({
method: 'GET',
url: '/cats',
});
then, each subsequent request will work. Will dig into this issue.
It should be fixed in 6.0.1 :) Please, let me know if you encounter any issues.
Now it works as expected.
Not related to this issue, but after testing routing I figured out that Swagger is not compatible with fastify after separation of express from core (so with v6). Is this ok (since after fast lookup of Swagger package, it depends on express) or should there be a fastify based Swagger package? If anything related to that should be contributed I can try to arrange my team to look at this.
@truewt I'll take care of swagger module shortly. :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
It should be fixed in 6.0.1 :) Please, let me know if you encounter any issues.