This happens when you have a proxy in front of you FastAPI.
FastAPI expects you to have the docs at the root of your URL
If the URL for the FastAPI is https://www.example.com/example/api/
add:
app = FastAPI(
root_path="/example/api/"
)
This way https://www.example.com/example/api/docs will work