File tree Expand file tree Collapse file tree
stac_fastapi/api/stac_fastapi/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## [ Unreleased]
44
5+ ### Fixed
6+
7+ - swap usage of vendored ` CORSMiddleware ` for the official one from starlette
8+ - add deprecatation warning for ` stac_fastapi.api.middleware.CORSMiddleware `
9+
510## [ 6.2.0] - 2026-01-13
611
712### Removed
Original file line number Diff line number Diff line change 1313from stac_pydantic .shared import MimeTypes
1414from stac_pydantic .version import STAC_VERSION
1515from starlette .middleware import Middleware
16+ from starlette .middleware .cors import CORSMiddleware
1617from starlette .responses import Response
1718
1819from stac_fastapi .api .errors import DEFAULT_STATUS_CODES , add_exception_handlers
19- from stac_fastapi .api .middleware import CORSMiddleware , ProxyHeaderMiddleware
20+ from stac_fastapi .api .middleware import ProxyHeaderMiddleware
2021from stac_fastapi .api .models import (
2122 APIRequest ,
2223 CollectionUri ,
@@ -126,7 +127,14 @@ class StacApi:
126127 default = attr .Factory (
127128 lambda : [
128129 Middleware (BrotliMiddleware ),
129- Middleware (CORSMiddleware ),
130+ Middleware (
131+ CORSMiddleware ,
132+ # Set CORS defaults to those recommended by the STAC API spec
133+ allow_origins = ["*" ],
134+ allow_methods = ["OPTIONS" , "POST" , "GET" ],
135+ allow_headers = ["Content-Type" ],
136+ max_age = 600 ,
137+ ),
130138 Middleware (ProxyHeaderMiddleware ),
131139 ]
132140 )
Original file line number Diff line number Diff line change 33import contextlib
44import re
55import typing
6+ import warnings
67from http .client import HTTP_PORT , HTTPS_PORT
78from typing import List , Optional , Tuple
89
@@ -31,17 +32,25 @@ def __init__(
3132 allow_origin_regex : typing .Optional [str ] = None ,
3233 expose_headers : typing .Sequence [str ] = (),
3334 max_age : int = 600 ,
35+ ** kwargs : typing .Any ,
3436 ) -> None :
3537 """Create CORS middleware."""
38+ warnings .warn (
39+ """stac_fastapi.api.middleware.CORSMiddleware is deprecated and
40+ will be removed in a future release.
41+ Please use starlette.middleware.cors.CORSMiddleware instead.""" ,
42+ DeprecationWarning ,
43+ )
3644 super ().__init__ (
3745 app ,
38- allow_origins ,
39- allow_methods ,
40- allow_headers ,
41- allow_credentials ,
42- allow_origin_regex ,
43- expose_headers ,
44- max_age ,
46+ allow_origins = allow_origins ,
47+ allow_methods = allow_methods ,
48+ allow_headers = allow_headers ,
49+ allow_credentials = allow_credentials ,
50+ allow_origin_regex = allow_origin_regex ,
51+ expose_headers = expose_headers ,
52+ max_age = max_age ,
53+ ** kwargs ,
4554 )
4655
4756
You can’t perform that action at this time.
0 commit comments