강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của devops4574
devops4574

câu hỏi đã được viết

NestJS phụ trợ vững chắc, từ cơ bản đến nâng cao

Cài đặt bảo mật API Swagger & Kết nối với giao diện API đăng nhập

expressBasicAuth 에러

Viết

·

410

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

Câu trả lời 2

4

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

1

amamov님의 프로필 이미지
amamov
Người chia sẻ kiến thức

안녕하세요! :)

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

devops님의 프로필 이미지
devops
Người đặt câu hỏi

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

Hình ảnh hồ sơ của devops4574
devops4574

câu hỏi đã được viết

Đặt câu hỏi