Compare commits

..

2 Commits

Author SHA1 Message Date
Peter J. Holzer 4af21972a9 Add ProxyHeadersMiddleware to parse X-Forwarded-Proto header
Starlett will automatically generate redirects to add or remove trailing
slashes as appropriate. To do this it needs to know the protocol,
however. This is usually passed by the proxy in the X-Forwarded-Proto
header.
2021-08-01 17:01:52 +02:00
Peter J. Holzer 5ddf0bc9c5 Require gunicorn 2021-08-01 17:00:57 +02:00
2 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,11 @@
from fastapi import FastAPI from fastapi import FastAPI
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
app = FastAPI() app = FastAPI()
app.add_middleware(
ProxyHeadersMiddleware, trusted_hosts=[None]
)
@app.get("/f1") @app.get("/f1")
async def f1(): async def f1():
return { return {

View File

@ -1,2 +1,3 @@
fastapi fastapi
uvicorn uvicorn
gunicorn