2

Hi i am trying to register the @fastify/cookie plugin to my nestjs backend but i have an error and i don't know why because in previous code i was doing the same thinks and was working , i don't know if versions changed or if there is a new way of registering plugins with nestJs -> Fastify

here is my code

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import fastifyCookie from '@fastify/cookie';

async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
  AppModule,
  new FastifyAdapter(),
);

await app.register(fastifyCookie, { secret: '' });
await app.listen(3005);
}

bootstrap();

and i am getting

Argument of type 'FastifyCookie' is not assignable to parameter of type 'FastifyPluginCallback<FastifyCookieOptions, RawServerDefault, FastifyTypeProviderDefault, FastifyBaseLogger> | FastifyPluginAsync<...> | Promise<...> | Promise<...>'

here are the versions i am using

  • "@nestjs/core": "^9.3.9"
  • "@nestjs/platform-fastify": "^9.2.0"
  • "@fastify/cookie": "^8.3.0",
Alexandre29
  • 57
  • 2
  • 8
  • I'm getting the same error. – m8a Mar 24 '23 at 06:54
  • Hehe... I went to test this in a new virgin Nest project and low and behold, the issue wasn't there. So, I upgraded all my packages for Nest and low and behold, the issue is gone too. It must have been fixed. Now using 9.3.12. – m8a Mar 24 '23 at 08:22
  • Damn, did an upgrade again and now I'm getting this error again. So frustrating.... – m8a Jul 02 '23 at 09:24

0 Answers0