Skip to content

Commit e479a23

Browse files
authored
Merge pull request #221 from stac-utils/gateway-api-env-var
Add API root path environment variable
2 parents 0ac4d2f + 937c77f commit e479a23

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- use index templates for Collection and Item indices [#208](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions/208)
1313
- Added API `title`, `version`, and `description` parameters from environment variables `STAC_FASTAPI_TITLE`, `STAC_FASTAPI_VERSION` and `STAC_FASTAPI_DESCRIPTION`, respectively. [#207](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/207)
14+
- Added a `STAC_FASTAPI_ROOT_PATH` environment variable to define the root path. Useful when working with an API gateway or load balancer. [#221](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/221)
15+
1416

1517
### Changed
1618

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ curl -X "POST" "http://localhost:8080/collections" \
8282

8383
Note: this "Collections Transaction" behavior is not part of the STAC API, but may be soon.
8484

85+
## Configure the API
86+
87+
By default the API title and description are set to `stac-fastapi-<backend>`. Change the API title and description from the default by setting the `STAC_FASTAPI_TITLE` and `STAC_FASTAPI_DESCRIPTION` environment variables, respectively.
88+
89+
By default the API will read from and write to the `collections` and `items_<collection name>` indices. To change the API collections index and the items index prefix, change the `STAC_COLLECTIONS_INDEX` and `STAC_ITEMS_INDEX_PREFIX` environment variables.
90+
91+
The application root path is left as the base url by default. If deploying to AWS Lambda with a Gateway API, you will need to define the app root path to be the same as the Gateway API stage name where you will deploy the API. The app root path can be defined with the `STAC_FASTAPI_ROOT_PATH` environment variable (`/v1`, for example)
8592

8693
## Collection pagination
8794

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
search_post_request_model=post_request_model,
7676
)
7777
app = api.app
78+
app.root_path = os.getenv("STAC_FASTAPI_ROOT_PATH", "")
7879

7980

8081
@app.on_event("startup")

stac_fastapi/opensearch/stac_fastapi/opensearch/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
search_post_request_model=post_request_model,
7676
)
7777
app = api.app
78+
app.root_path = os.getenv("STAC_FASTAPI_ROOT_PATH", "")
7879

7980

8081
@app.on_event("startup")

0 commit comments

Comments
 (0)