Skip to content

Commit e3fd5cd

Browse files
committed
Allow CORS requests from all origins
1 parent 3cf4025 commit e3fd5cd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

stac_search/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from fastapi import FastAPI
6+
from fastapi.middleware.cors import CORSMiddleware
67
from pydantic import BaseModel
78
import uvicorn
89

@@ -16,6 +17,15 @@
1617
version="0.1.0",
1718
)
1819

20+
# Add CORS middleware
21+
app.add_middleware(
22+
CORSMiddleware,
23+
allow_origins=["*"], # Allows all origins
24+
allow_credentials=True,
25+
allow_methods=["*"], # Allows all methods
26+
allow_headers=["*"], # Allows all headers
27+
)
28+
1929

2030
# Define request model
2131
class QueryRequest(BaseModel):

0 commit comments

Comments
 (0)