Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CORS middleware to support requests from other origins #6

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/aross_stations_db/api/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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("/")
Expand Down
2 changes: 1 addition & 1 deletion src/aross_stations_db/api/v1/climatology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/aross_stations_db/api/v1/stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/aross_stations_db/api/v1/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading