Skip to content

Commit 9ce6fe4

Browse files
fix: unpin starlette and use official CORSMiddleware (#95)
1 parent 2970a69 commit 9ce6fe4

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies = [
2121
"stac-fastapi.types",
2222
"stac-pydantic==3.1.*",
2323
"brotli-asgi",
24-
"starlette < 0.51.0",
24+
"starlette",
2525
"typing_extensions",
2626
"shapely",
2727
]

stac_fastapi/eodag/app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from fastapi.middleware import Middleware
3030
from fastapi.responses import ORJSONResponse
3131
from stac_fastapi.api.app import StacApi
32-
from stac_fastapi.api.middleware import CORSMiddleware
3332
from stac_fastapi.api.models import (
3433
EmptyRequest,
3534
ItemCollectionUri,
@@ -48,6 +47,7 @@
4847
from stac_fastapi.extensions.core.pagination.token_pagination import TokenPaginationExtension
4948
from stac_fastapi.extensions.core.query import QueryConformanceClasses
5049
from stac_fastapi.extensions.core.sort import SortConformanceClasses
50+
from starlette.middleware.cors import CORSMiddleware
5151

5252
from stac_fastapi.eodag.config import get_settings
5353
from stac_fastapi.eodag.core import EodagCoreClient
@@ -225,7 +225,14 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
225225
items_get_request_model=item_collection_model,
226226
middlewares=[
227227
Middleware(BrotliMiddleware),
228-
Middleware(CORSMiddleware),
228+
Middleware(
229+
CORSMiddleware,
230+
# Set CORS defaults to those recommended by the STAC API spec
231+
allow_origins=["*"],
232+
allow_methods=["OPTIONS", "POST", "GET"],
233+
allow_headers=["Content-Type"],
234+
max_age=600,
235+
),
229236
Middleware(ProxyHeaderMiddleware),
230237
],
231238
)

0 commit comments

Comments
 (0)