ojoanalogo / nestjs-redoc

📘 ReDoc frontend for you NestJS swagger API documentation
MIT License
146 stars 55 forks source link

TypeError: Cannot read property 'enabled' of undefined #21

Closed cerireyhan closed 3 years ago

cerireyhan commented 3 years ago

NestJS server fails with error when redoc options doesn't have 'auth' optional parameter because of the line 135 of redoc-module.ts below.

if (options.auth.enabled) { const { user, password } = options.auth; expressAuth({ users: { [user]: password }, challenge: true })( req, res, () => { sendPage(); } ); } else { sendPage(); }

Also, I'm not sure if it makes sense to have auth optional option, but user & password required. What if enabled is false?

auth?: { enabled: boolean; user: string; password: string; };

ojoanalogo commented 3 years ago

Thanks, I forgot to check value of property 🤯

Fixed on 2.0.3 version, please update.

As per your suggestion for auth as optional option I agree, although that would require to bump major package version to 3.x.x since it would be a breaking change