-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing to fix the request base URL via an env var #582
Conversation
from starlette.requests import Request | ||
|
||
|
||
def get_base_url(request: Request) -> str: | ||
"""Get base URL with respect of APIRouter prefix.""" | ||
if base_url := os.environ.get("REQUEST_BASE_URL"): | ||
return base_url | ||
|
||
app = request.app | ||
if not app.state.router_prefix: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason to not use the same mechanism as router_prefix
, i.e. add a new base_url: Optional[str]
attribute to the app state?
As for #636, I'm not convince we need this. If the baseurl is not properly returned by starlette it usually mean there is a configuration issue in the proxy 🤔 |
Should we close this for now? |
@jonhealy1 IMO yes |
closing ..... feel free to reopen |
Related Issue(s):
Description:
A new env var
REQUEST_BASE_URL
is introduced to fix the base URL to the supplied value. When this variable is not set, the usual way of determining the base URL is used.PR Checklist:
pre-commit
hooks pass locallymake test
)make docs
)