Skip to content

Commit

Permalink
Fix for Starlette CORS
Browse files Browse the repository at this point in the history
The Starlette app with setting cors=true enables all origins, but only permits requests with the GET method. The CORSMiddleware for Starlette requires specifying `allow_methods=['*']` to enable all common request methods.
  • Loading branch information
ptomasula committed Jul 19, 2024
1 parent 33c5e25 commit caf374c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pygeoapi/starlette_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ async def __call__(self, scope: Scope,
# CORS: optionally enable from config.
if CONFIG['server'].get('cors', False):
from starlette.middleware.cors import CORSMiddleware
APP.add_middleware(CORSMiddleware, allow_origins=['*'])
APP.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=['*'])

try:
OGC_SCHEMAS_LOCATION = Path(CONFIG['server']['ogc_schemas_location'])
Expand Down

0 comments on commit caf374c

Please sign in to comment.