D
D
Denis Sokolov2021-08-27 13:12:24
Node.js
Denis Sokolov, 2021-08-27 13:12:24

Why session is not saved in NESTJS?

import { NestFactory } from '@nestjs/core';
import * as session from 'express-session';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.use(
    session({
      secret: 'my-secret',
      resave: true,
      saveUninitialized: true,
    }),
  );
  app.enableCors();
  await app.listen(3001);
}
bootstrap();

session.user = user;
session.isAuth = true;
await session.save((err) => {
    if (err) console.log(err);
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question