Support X-Forwarded-Host in proxy-headers
Author: retrryCreated Feb 24, 2021Updated Aug 6, 2026
Checklist
- There are no similar issues or pull requests for this yet.
- I discussed this idea on the community chat and feedback is positive.
Is your feature related to a problem? Please describe.
When using uvicorn, with starlette URLs with url_for are generated with bad host, when application is behind proxy and proxy sets original host to X-Forwarded-Host.
https://github.com/encode/starlette/issues/604
Describe the solution you would like.
Currently uvicorn uses only X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate scope with remote information. But there is X-Forwarded-Host header, which should be used for populating server information in scope.
Source: Kludex/uvicorn