Questions tagged [nestjs-fastify]
36 questions
1
vote
1 answer
How to add custom content type parser for Nest with Fastify
I need to overwrite the content parser for application/json so my application accepts empty body. Right now it throws:
{
"statusCode": 400,
"code": "FST_ERR_CTP_EMPTY_JSON_BODY",
"error": "Bad Request",
"message": "Body cannot be…

mardok
- 2,135
- 2
- 23
- 37
1
vote
2 answers
How to configure Helmet in a Nestjs project using Fastify?
I'm using Nestjs (7.x) and Fastify (with @nestjs/platform-fastify).
I'm trying to install Helmet in my project (fastify-helmet), but I'm not able to figure how to integrate/configure it with Nestjs. What's the proper way to have it onboard?
Here is…

Etienne
- 2,257
- 3
- 27
- 41
0
votes
0 answers
how to unit test nest with fastify
I searched the documentation for Next, but I didn't find much on how to unit test main.ts
async function bootstrap() {
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
…
0
votes
0 answers
How do I drain my Fastify GraphQL server on shutdown with Nest.JS?
I have a Nest.js application with GraphQL and Fastify. If a request is ongoing while the application is shutting down, I am receiving this error:
A GraphQL operation was received during server shutdown. The operation will fail. Consider draining…

FooBar
- 5,752
- 10
- 44
- 93
0
votes
0 answers
Fastify CSRF does not create a header or cookie and does not check it
I have a frontend in NextJS and a backend in NestJS. I noticed that the token is not checked on the back-end side, nor is any X-CSRF-TOKEN header or cookie created, even though the code is in accordance with the documentation. After researching and…

Tebyy
- 53
- 5
0
votes
1 answer
NestJS 9.4.0 crashes while creating Fastify app
I installed Throttler for NestJS 9.4.0 application to secure it but it gives me an error when i use NestFastify anyone know how it should look like correctly? A needs to use Fastify for subsequent security such as CSRF. I've been struggling with…

Tebyy
- 53
- 5
0
votes
0 answers
Upload File with nest fastify multer "Unsupported Media Type"
Im trying to import a file using nest fastify multer but im receiving:
I dont know how to solve it
the controller:
theoretically, everything is already set up, if you need more prints I can edit the question
Can u guys please help me?
Ive tried to…

Pedro Ventura
- 13
- 4
0
votes
1 answer
How to register cookie middleware for e2e testing?? - @nestjs/testing and fastify adapter
I use pactum and jest for e2e testing
but while testing the endpoint which sets cookies, nest throws an error
[Nest] 3364 - 01/03/2023, 5:35:15 PM ERROR [ExceptionsHandler] response.setCookie is not a function
TypeError: response.setCookie is not…
0
votes
1 answer
In NestJs can I use an interceptor and the @Response parameter status setter?
I have a NestJs application that uses an interceptor to wrap all http responses much like the example in the docs https://docs.nestjs.com/interceptors ...
@Injectable()
export class TransformInterceptor implements NestInterceptor>…

okhobb
- 758
- 8
- 22
0
votes
1 answer
Apply fastifySession Middleware in nest js - Using the MiddlewareConsumer in the AppModule
I have a Nestjs app with Fastify. I want to apply the fastifySession middleware using the MiddlewareConsumer. Usually, it works like below:
configure(consumer: MiddlewareConsumer) {
consumer
.apply(
fastifySession,
)
…

Mohamed Gad
- 56
- 1
- 9
0
votes
1 answer
How to use cookie in middleware of Nest JS ( Fastify )
I'm using
Nestjs CLI 9.0.0
Nestjs common - Nestjs Platform Fastify 9.0.11
Fastify - 4.4.0
@fastify/cookie - 8.0.0
I try to use cookie and set cookie in middleware.
But it seems all about cookie is undefined.
this.logger.debug("cookies",…

armada45
- 103
- 9
0
votes
1 answer
Nestjs versioning configuration when using Fastify
For performance reasons of a relatively complex Nestjs application, we have chosen to use Fastify as our HTTP provider.
We are at a stage where we need to version out api and are running into problems after following instructions on the standard…

Mr Citizen
- 37
- 1
- 5
0
votes
0 answers
Not able to update req url since req.raw is undefined in nestjs fastify custom middleware
I have applied middleware to one of my application in Nestjs Fastify.
In middleware I want to access userId from req url and remove it from there. Since I was using FastifyRequest as a req type I was not able to reassign req.url.
I got to know that…

Raj
- 598
- 5
- 23
0
votes
1 answer
Why does specifying the URL as '0.0.0.0' allow my NestJS-fastify app to deploy to Heroku?
When I was trying to deploy my NestJS app to Heroku I was seeing the error Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Why does setting the url to 0.0.0.0 make it work?
const port = process.env.PORT ||…

Grayson Ricketts
- 13
- 1
- 3
0
votes
1 answer
How to serve multiple SPA in nestjs using fastify
The configuration mentioned below works absolutely fine with express but it is giving error when used with fastify.
export const serveStaticModule_one: ServeStaticModuleOptions = {
rootPath: join(process.cwd(), 'one')
};
export const…

Amit Kumar
- 620
- 4
- 17