Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ In version `6.0.0` we've renamed the PG configuration variable to match the offi
- `CORS_ORIGINS`: A list of origins that should be permitted to make cross-origin requests. Defaults to `*`
- `CORS_METHODS`: A list of HTTP methods that should be allowed for cross-origin requests. Defaults to `"GET,POST,OPTIONS"`
- `CORS_CREDENTIALS`: Set to `true` to enable credentials via CORS requests. Note that you'll need to set `CORS_ORIGINS` to something other than `*`, because credentials are [disallowed](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors/CORSNotSupportingCredentials) for wildcard CORS origins.
- `CORS_HEADERS`: If `CORS_CREDENTIALS` are true and you're using an `Authorization` header, set this to `Content-Type,Authorization`. Alternatively, you can allow all headers by setting this to `*`.
- `USE_API_HYDRATE`: perform hydration of stac items within stac-fastapi
- `INVALID_ID_CHARS`: list of characters that are not allowed in item or collection ids (used in Transaction endpoints)
1 change: 1 addition & 0 deletions stac_fastapi/pgstac/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ async def lifespan(app: FastAPI):
allow_origins=settings.cors_origins,
allow_methods=settings.cors_methods,
allow_credentials=settings.cors_credentials,
allow_headers=settings.cors_headers,
),
],
health_check=health_check,
Expand Down
6 changes: 6 additions & 0 deletions stac_fastapi/pgstac/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Settings(ApiSettings):
cors_origins: str = "*"
cors_methods: str = "GET,POST,OPTIONS"
cors_credentials: bool = False
cors_headers: str = "Content-Type"

testing: bool = False

Expand All @@ -183,3 +184,8 @@ def parse_cors_origin(cls, v):
def parse_cors_methods(cls, v):
"""Parse CORS methods."""
return [method.strip() for method in v.split(",")]

@field_validator("cors_headers")
def parse_cors_headers(cls, v):
"""Parse CORS headers."""
return [header.strip() for header in v.split(",")]
Loading