Trying to follow https://fastapi.tiangolo.com/advanced/behind-a-proxy/?h=proxy#proxy-with-a-stripped-path-prefix but keep getting 403 when I trying to access /docs or /redoc:
I get the 403 error(image attached) if I do the below:
app = FastAPI(
servers=servers,
root_path="/latest", # Same 403 error without the root_path or omitting it
root_path_in_servers=True, # Same issue when setting to False or omitting it
/docs and /redoc works locally, just not once I push it to AWS APIGW/Lambdaroot_path and root_path_in_servers=True or False and had the same issueGET /docs path setup to route to the Lambdaapi.example.com > API GW CloudFront URL which is mapped to my APIGW stage named /latest, then it sends to LambdaI also reviewed this post with a similar/same issue, and tried:
docs_url='/latest/docs',
redoc_url='/latest/redoc',
openapi_url='/latest/openapi.json'
but encountered the same 403 error(image attached) or {"detail":"Not Found"}
app = FastAPI(openapi_prefix='/dev/')
This worked for me. Here, dev is the API stage name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With