Fastapi: [Bug] Documentation Failed to fetch /openapi.json

Created on 29 Jul 2020  路  2Comments  路  Source: tiangolo/fastapi

When I click https://host/suburl/documentation

I have a "Failed to load definition".

In the console, I have

Error downloading https://host/openapi.json Failed to fetch

My code looks like that:

from fastapi import FastAPI

app = FastAPI(openapi_url="/openapi.json", docs_url="/documentation")

@app.get("/status")
def return_simple():
    return "ok"
I can't find an anwser for this problem. Do you have any idea?

question

Most helpful comment

I found a solution. I launched fastapi with a "root-path" like this:

uvicorn fast_api.server:app --host 0.0.0.0 --port 8000 --root-path="/suburl"

All 2 comments

I found a solution. I launched fastapi with a "root-path" like this:

uvicorn fast_api.server:app --host 0.0.0.0 --port 8000 --root-path="/suburl"

Thanks for reporting back and closing the issue :+1:

Was this page helpful?
0 / 5 - 0 ratings