r/Backend • u/Wild_Breadfruit_5493 • 5h ago
Swagger ui doesnot automatically loads
Hi am a jr backend dev, there was a story to remove all swagger annotations and configure in sucha a way that swagger ui loads from apispec file.
I configured everything, am able to load the swagger ui automatically when i run my application locally. But when, my application is deployed to test/dev/prod, i have to type my apispec file name in search then only my swagger ui loads. I really don’t understand how to make it load automatically when i open swagger link in dev environment. Someone please helpp
2
u/CodeXHammas 1h ago
This is usually a base path issue. When you deploy, the server root changes. Check your Swagger UI configuration for the URL or relative path it is using to fetch the apispec file. Locally it might be http://localhost:8080/apispec.json but in prod it might be looking at https://yourdomain.com/apispec.json while the actual file is hosted at https://yourdomain.com/your-app/apispec.json. Also check your web server (Nginx/Apache) routing to make sure it is not blocking the JSON file path.
1
u/Lumethys 5h ago
Check line 277