nestjs-redoc icon indicating copy to clipboard operation
nestjs-redoc copied to clipboard

Cant load swagger file in Nest app running with url prefix

Open mo4islona opened this issue 3 years ago • 0 comments

We should load swagger from relative url because nest application could be proxied with some path prefix by some server like NGINX behind.

For example, we have Nest app with simple /docs/ route. And some SPA application on same domain. We will configure NGINX like

location /api {
   // upstream to Nest app
}

location {
 // route everything didnt match /api prefix to static files
}

In these cause a broken link swagger.json because it will be generated from the root

And these why all static files are loaded in original SwaggerModule

<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script src="./swagger-ui-init.js"> </script>

mo4islona avatar Apr 28 '21 18:04 mo4islona