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

DRAFT: Add CORSmiddleware #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions cid/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@

# Supported cloud providers.
CLOUD_PROVIDERS = ["aws", "azure", "google"]

# Allowed origins for CORS.
CORS_ORIGINS = [
"https://cloudx-cidv2.fly.dev/",
]
12 changes: 11 additions & 1 deletion cid/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

from fastapi import Depends, FastAPI, HTTPException, Request
from fastapi.encoders import jsonable_encoder
from fastapi.middleware.cors import CORSMiddleware
from schedule import every, repeat, run_pending
from sqlalchemy.orm import Session

from cid import crud
from cid.config import ENVIRONMENT
from cid.config import CORS_ORIGINS, ENVIRONMENT
from cid.database import SessionLocal

log = logging.getLogger(__name__)
Expand All @@ -18,6 +19,15 @@
app = FastAPI()


app.add_middleware(
CORSMiddleware,
allow_origins=CORS_ORIGINS,
allow_credentials=True,
allow_methods=["GET"],
allow_headers=["*"],
)


def get_db() -> Generator:
db = SessionLocal()
try:
Expand Down
56 changes: 55 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ httpx = "^0.27.0"
schedule = "^1.2.2"
python-dateutil = "^2.9.0-post.0"
packaging = "^24.1"
fastapi-cors = "^0.0.6"

[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"
Expand Down