Submission error! response.header is not a function in nest-fastify graphql

Submission error! response.header is not a function in nest-fastify graphql


0

I need set header autorization client. But have error in my Mutation "Submission error! response.header is not a function".

my main.ts

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(),
  );
  await app.enableCors({
    origin: true,
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
    credentials: true,
  });
  await app.useGlobalPipes(new ValidationPipe({ stopAtFirstError: true }));
  await app.register(fastifyCookie, {
    secret: 'secret',
  });
  await app.listen(3500);
}

my resolver

@Mutation((returns) => AccessToken, { nullable: true })
  async registerUser(
    @Args('createUser') createUserInput: CreateUserInput,
    @Res({ passthrough: true }) response: FastifyReply,
  ): Promise<{ token: string }> {
    const token = await this.userService.registerUser(createUserInput);

    // await response.setCookie('token_auth', token, { httpOnly: true });
    // response.signCookie('Bearer ' + token);
    await response.header('Authorization', 'Bearer ' + token);
    // await response.cookie('token_auth', token, { httpOnly: true });
    return { token: token };
  } 

New contributor

PovarCoda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *