diff --git a/src/aross_stations_db/api/__init__.py b/src/aross_stations_db/api/__init__.py index f3d0e7a..1d06b7e 100644 --- a/src/aross_stations_db/api/__init__.py +++ b/src/aross_stations_db/api/__init__.py @@ -1,4 +1,5 @@ from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from aross_stations_db.api.v1.routes import router as v1_router @@ -9,6 +10,13 @@ ), ) api.include_router(v1_router, prefix="/v1", tags=["v1"]) +api.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) @api.get("/") diff --git a/src/aross_stations_db/middleware.py b/src/aross_stations_db/api/dependencies.py similarity index 100% rename from src/aross_stations_db/middleware.py rename to src/aross_stations_db/api/dependencies.py diff --git a/src/aross_stations_db/api/v1/climatology.py b/src/aross_stations_db/api/v1/climatology.py index b5f70b2..3a10f50 100644 --- a/src/aross_stations_db/api/v1/climatology.py +++ b/src/aross_stations_db/api/v1/climatology.py @@ -5,11 +5,11 @@ from geoalchemy2 import WKTElement from sqlalchemy.orm import Session +from aross_stations_db.api.dependencies import get_db_session from aross_stations_db.api.v1.output import ( ClimatologyJsonElement, climatology_query_results_to_json, ) -from aross_stations_db.middleware import get_db_session from aross_stations_db.query import climatology_query router = APIRouter() diff --git a/src/aross_stations_db/api/v1/stations.py b/src/aross_stations_db/api/v1/stations.py index 3aebaf1..47ac6c1 100644 --- a/src/aross_stations_db/api/v1/stations.py +++ b/src/aross_stations_db/api/v1/stations.py @@ -5,11 +5,11 @@ from geoalchemy2 import WKTElement from sqlalchemy.orm import Session +from aross_stations_db.api.dependencies import get_db_session from aross_stations_db.api.v1.output import ( StationsGeoJson, stations_query_results_to_geojson, ) -from aross_stations_db.middleware import get_db_session from aross_stations_db.query import stations_query router = APIRouter() diff --git a/src/aross_stations_db/api/v1/timeseries.py b/src/aross_stations_db/api/v1/timeseries.py index 84ce26b..30cdc48 100644 --- a/src/aross_stations_db/api/v1/timeseries.py +++ b/src/aross_stations_db/api/v1/timeseries.py @@ -5,11 +5,11 @@ from geoalchemy2 import WKTElement from sqlalchemy.orm import Session +from aross_stations_db.api.dependencies import get_db_session from aross_stations_db.api.v1.output import ( TimeseriesJsonElement, timeseries_query_results_to_json, ) -from aross_stations_db.middleware import get_db_session from aross_stations_db.query import timeseries_query router = APIRouter()