Skip to main content

2 posts tagged with "nestjs"

View All Tags

· 3 min read
Phạm Quyết Thắng
Fullstack developer

Swagger is a powerful tool for creating and managing API documentation. However, securing Swagger documents is crucial to ensure that sensitive information is not exposed. In this article, we will explore how to use the express-basic-auth library to protect Swagger documentation pages in JavaScript and TypeScript projects. We will focus on two cases: a regular JavaScript/TypeScript project and a NestJS project with @nestjs/swagger.

After implementation, a user/password input form will appear when accessing the document page, and the correct credentials must be entered to view the document:

Basic auth