강의

멘토링

커뮤니티

Inflearn Community Q&A

devops4574's profile image
devops4574

asked

Solid backend NestJS, from basics to advanced

Swagger API Security Configuration & Login API Frontend Connection

expressBasicAuth 에러

Written on

·

403

1

(node:33188) UnhandledPromiseRejectionWarning: TypeError: (0 , express_basic_auth_1.default) is not a function

    at bootstrap (C:\Users\dial\NestJS\working\letsstart\project\src\main.ts:15:21)

    at processTicksAndRejections (internal/process/task_queues.js:95:5)

(Use `node --trace-warnings ...` to show where the warning was created)

(node:33188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

(node:33188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

위와 같은 오류가 뜨는데요

expressBasicAuth 미들웨어를 추가하니까 뜹니다. 이유가 무엇일까요..

 app.use(
    ['/docs''/docs-json'],
    expressBasicAuth({
      challenge: true,
      users: {
        [process.env.SWAAGER_USER]: process.env.SWAGGER_PASSWORD,
      },
    }),
 );
 
 

 

expressmongodbnodejsssrNestJS

Answer 2

4

import * as expressBasicAuth from 'express-basic-auth';

1

amamov님의 프로필 이미지
amamov
Instructor

안녕하세요! :)

해당 에러는 미들웨어에서 데이터 전달이 실패한 경우 많이 발생하는 에러입니다. 전체 코드 보여주실 수 있나요?

devops님의 프로필 이미지
devops
Questioner

해결되었습니다 감사합니당.!

devops4574's profile image
devops4574

asked

Ask a question