#Nestjs Swagger css not loading when deployed
23 messages · Page 1 of 1 (latest)
What does the browser console/network tab say?
This is on localhost. I deployed nest app to versel
Disable cache (the checkbox in the top bar of network tab) and do that again please. It's weird that js files are loading fine, but css is not.
Still the same sir😥
My vercel.json file
Hmm, I can reproduce that, but I don't really know what's going on.
NestJS is backend framework, and Vercel is mostly for hosting front-end stuff. It somehow managed to build the backend to somewhat working state, but it's not how Nest is meant to be deployed (unless you're setting up serverless, which is not my field).
Can you deploy elsewhere? I've recently recommended this article: https://blog.flycode.com/7-excellent-alternatives-to-heroku which lists easy to setup, with free tier hosting services that work good for running nest.
Ok...Thank you very much for your time. I am looking to this.
Did you get it working somewhere? 🙂
any luck on this? i also have the same issue and I don't have any luck on my workarounds
I think I may have found a solution...
for content I'm using nestjs/swagger for an azure function app based of nestjs/azure-func-http
my workaround was to remove those elements that throws a 404 error and replace them with their cdn resource. in my case the swagger-ui.css, swagger-ui-bundle.js and swagger-ui-standalone-preset.js cannot be found so I looked for their cdn's from swagger-ui. then add a customJS on SwaggerMod.setup call that points to the CDNs. in order to remove the elements that were throwing 404, i also added jquery cdn and added a jquery script to customJsStr. here's the complete solution:
not elegant but seems to work for me
I'm thinking there should be a way to declare your own htmlTemplateString when SwaggerMod.setup is called @haughty fox
after much investigation, seems like express is the problem. express could serve the index.html file from the swagger-ui-dist but for some reason when the .js and .css files are requested it gets stuck on pending status.
I'm not exactly sure if fastify would fix this
just tried fastify also doesn't seem to work
i resorted on extending the swaggermodule, removing any instances of getting js and css files from swagger-ui-dist and use thie swaggerUICdn instead
extending the swaggermodule was a bit tedious, it would have helped if the static method were exposed publicly include the buildSwaggerHTML for swagger doc
It's working with Railway.
So this seem an issue with Vercel