question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set root-path to uvicorn

See original GitHub issue

I’m trying to set root_path to uvicorn as suggested [1] using this image, but don’t see any options to pass arguments:

uvicorn main:app --root-path /api/v1

How can I do it?

Refs:

  1. https://fastapi.tiangolo.com/advanced/behind-a-proxy/#providing-the-root_path

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

13reactions
mindejcommented, Feb 25, 2021

@poppash On my side it does not work I am getting an error in OpenApi image

Python 3.7.8 fastapi 0.63.0

Run configuration: uvicorn.run(“app:app”, host=“0.0.0.0”, port=port, reload=True)

I think the error is in the path here is console log: 127.0.0.1:54913 - "GET /api/v1/api/v1/openapi.json HTTP/1.1" 404 Not Found Here is double path: /api/v1/api/v1/

5reactions
poppashcommented, Sep 9, 2020

I struggled with this as well. Got it working in the end, albeit by setting root_path via the FastAPI object, e.g., app = FastAPI(root_path='/api/v1') and upgrading FastAPI.

Before upgrading it didn’t work either using the current tiangolo/uvicorn-gunicorn-fastapi-docker:python3.8 image because it still has fastapi==0.55.1 installed. Try docker container run tiangolo/uvicorn-gunicorn-fastapi:python3.8 pip freeze | grep fastapi to verify. This image was last updated 3 months ago, probably just before the release of fastapi==0.56.0 (see PR).

Extending from tiangolo/uvicorn-gunicorn-fastapi-docker:python3.8 and then pip install --upgrade fastapi==0.61.1 did the trick for me.

@tiangolo will the images be updated in the near future?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Settings - Uvicorn
Use the following options to configure Uvicorn, when running from the ... --root-path <str> - Set the ASGI root_path for applications submounted below...
Read more >
fastapi dynamic root path - uvicorn - Stack Overflow
Wondering, if we can set the root path in a dynamic way in places like middleware where we can use x-forwarded header to...
Read more >
Behind a Proxy - FastAPI
In these cases you can use root_path to configure your application. ... And now start your app with Uvicorn, using the --root-path option:....
Read more >
Developers - set root-path to uvicorn - - Bountysource
I'm trying to set root_path to uvicorn as suggested [1] using this image, but don't see any options to pass arguments:
Read more >
tiangolo/fastapi - Gitter
... FastAPI applications to provide it in cases where it can be set with the command line (e.g. for Uvicorn and Hypercorn, with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found