inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

탄탄한 백엔드 NestJS, 기초부터 심화까지

Swagger API 보안 설정 & 로그인 API 프론트엔드와 연결

expressBasicAuth 에러

418

devops

작성한 질문수 2

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,
      },
    }),
 );
 
 

 

express mongodb nodejs ssr NestJS

답변 2

4

windflow

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

1

윤상석

안녕하세요! :)

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

0

devops

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

프로젝트 환경 세팅할 때 최신 노드 버젼을 사용하시는 분들은 참고하셔도 좋을 것 같아요~

2

81

1

DTO에 대한 질문

1

88

2

백엔드 MVC에서 View의 역할은 무엇인가요?

1

95

2

추가 업데이트 관련 건

0

92

2

nest js 버전문제

0

81

2

mongdb 스키마 공식 문서와 형태가 다른 이유 궁금합니다.

0

103

1

라인 끝에 에러 표시(eslint) 때문에 구글 찾아 보니.

0

76

1

전체 고양이 조회 라우터 중 error.message 오류

0

70

1

캡슐화 추가 설명 중 단일책임원칙 관련 질문

0

106

0

42강 고양이끼리 소통 댓글 구현 중 Schema hasn't been registered for model 'comments' 에러 해결

0

82

1

채팅 이슈

0

134

1

모듈이 더 이상 지원하지 않는답니다

0

207

1

오류가 있습니다

0

106

1

import 에서 오류가 납니다

0

128

1

이런 오류가 나옵니다

0

101

1

에러가 발생합니다

0

111

1

프론트 에러 뜨는데 수정 안해주시나요

0

159

1

emit() broadcast.emit() 질문있습니다

0

103

1

서버연결이 안됩니다.

1

403

1

[PM2][ERROR] Command not found

0

521

1

S3에 업로드까지는 성공했는데 사진이 나오지 않습니다.

0

248

1

error_code : Property 'user' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.ts(2339)

0

603

1

jwt를 따로 연습하고 있는데 env를 못읽는 것 같습니다.

0

324

2

Ec2로 안하시는 이유가 있을까요?

0

343

1