작성
·
1.4K
1
db연결은 잘되는데
쿼리 날리면 아래 에러가 뜨네요.
express-session 설치해봤는데 동일 메세지가 나옵니다.
ERROR [ExceptionsHandler] Login sessions require session support. Did you forget to use `express-session` middleware?
Error: Login sessions require session support. Did you forget to use `express-session` middleware?
at SessionStrategy.authenticate (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/passport/lib/strategies/session.js:46:41)
at attempt (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/passport/lib/middleware/authenticate.js:369:16)
at authenticate (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/passport/lib/middleware/authenticate.js:370:7)
at Layer.handle [as handle_request] (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/index.js:317:13)
at /Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/index.js:335:12)
at next (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/index.js:275:10)
at initialize (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/passport/lib/middleware/initialize.js:89:5)
at Layer.handle [as handle_request] (/Users/jinsyu/dev/teaching-typeorm-in-the-nest-main/node_modules/express/lib/router/layer.js:95:5)
답변 3
0
2023-02-12 :
passport 미들웨어 사용보다 위에 적어주셔야 동작하였습니다.
private async setUpGlobalMiddleware() {
this.server.enableCors({
origin: this.corsOriginList,
credentials: true,
})
this.server.use(cookieParser())
this.setUpBasicAuth()
this.setUpOpenAPIMidleware()
this.server.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
)
// 이 부분 적용
this.server.use(
expressSession({
secret: 'SECRET',
resave: true,
saveUninitialized: true,
}),
)
// -----------------
this.server.use(passport.initialize())
this.server.use(passport.session())
this.server.useGlobalInterceptors(
new ClassSerializerInterceptor(this.server.get(Reflector)),
)
this.server.useGlobalFilters(new HttpApiExceptionFilter())
}
0
0
안녕하세요!
해당 에러가 발생하는 경우
main.ts에서 express-session 미들웨어를 등록해주세요!
import * as expressSession from "express-session";
...
app.use(expressSession);
...