developmentseed / eoapi-cdk

AWS CDK constructs for deploying eoAPI
https://developmentseed.org/eoapi-cdk
11 stars 4 forks source link

broken custom domain name ingestor `/docs` endpoint #79

Closed emileten closed 1 year ago

emileten commented 1 year ago

cc @jjfrench since you worked on the custom domain name PR!

The set up for the ingestor is as follows :

  1. one lambda is deployed as an "API handler", integrated to an API gateway REST API. It's the entry point for the ingestion execution, and the FastAPI application is defined and deployed in that lambda. The handler file imports our custom FastAPI application.
  2. another lambda, called by the above, handles ingestions themselves, with this other custom application.

In (1), we allow for a root_path in the configuration, in cases e.g. where we want to define different stages in our proxy. With the current set up, all is well if we integrate (1) with an API gateway REST API as proxy.

However, if on top of that we map that REST API to a custom domain name, I noticed that the /docs endpoint is inaccessible. More specifically, it returns something like this :

Screenshot 2023-10-13 at 4 38 32 PM

I noticed that doing this solves the problem, but I am not sure to understand 100% why yet. [Taken from here]. The solution is, in the handler in (1), to pass to the Mangum constructor's api_gateway_base_path parameter the value of root_path.

Like this :

from mangum import Mangum

from .main import app

handler = Mangum(app, lifespan="off", api_gateway_base_path=app.root_path) # or something like that if the root path is exposed
### Tasks
- [ ] pass FastAPI `root_path` to Mangum `api_gateway_base_path` in the ingestor