Great post, actually the only one I found! A possible security oversight: /docs-json is not protected by this. Therefore use an array for the basic auth ['/docs', '/docs-json']. Also I would recommend using the ConfigurationService instead of directly accessing the env variables.
Full Stack JavaScript Developer in Brandenburg.
Creator of Monitornator.
Angular, Svelte, Vue, Ionic, Capacitor, Cordova, NestJS, Express.
Making the web awesome since 2002.
Also: πΊ ππΌββοΈ π· βοΈ π
Cool! You can use the JSON format of your OpenAPI with other generator tools for example to generate types and fetch functions for your frontend application.
The ConfigurationService would simply be the most NestJS way of doing it. Itβs awesome to validate your envs so you donβt forget about configuring something. But itβs not necessary, just a further read: docs.nestjs.com/techniques/configu...
Great post, actually the only one I found! A possible security oversight:
/docs-json
is not protected by this. Therefore use an array for the basic auth['/docs', '/docs-json']
. Also I would recommend using theConfigurationService
instead of directly accessing the env variables.I adapted your solution on this stackoverflow: stackoverflow.com/questions/548028...
Thanks @kiwikilian!
I updated my post with your proposal. Honestly, I did not know about the
-json
part, it is cool though!I also was wondering why using
ConfigurationService
instead of directly accessing the env variables would be a better idea?Cool! You can use the JSON format of your OpenAPI with other generator tools for example to generate types and fetch functions for your frontend application.
The
ConfigurationService
would simply be the most NestJS way of doing it. Itβs awesome to validate your envs so you donβt forget about configuring something. But itβs not necessary, just a further read: docs.nestjs.com/techniques/configu...@mahnuh another update, there is also
/docs-yaml
, so best is to secure with regex/docs*
or name all three paths explicitly.