Skip to content
Discussion options

You must be logged in to vote

When you use root_path='/api' parameter in FastAPI() it will make all your endpoint accessible via two paths: 1) normal (http://localhost:5000/v1/healthcheck) and 2) prefixed (http://localhost:5000/api/v1/healthcheck).

As I understand this is done this way to make the app compatible with different ASGI servers (not sure about this).

To make it accessible by only normal paths you can remove that parameter from FastAPI() and pass it to uvicorn.run() (you should run your app behind the stripping path proxy, otherwise it will fail to show docs):

import uvicorn
from fastapi import FastAPI, APIRouter

router = APIRouter(prefix='/v1')


@router.get('/healthcheck', tags=['Healthcheck'])
def check…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants