Skip to content

Commit

Permalink
fix: only take upto the netloc of the frontend url
Browse files Browse the repository at this point in the history
  • Loading branch information
bitmap4 committed Dec 24, 2024
1 parent dbefacf commit b413e11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .config import FRONTEND_URL, SessionLocal
from sqlalchemy import inspect
from .models import Base, CourseDB
from urllib.parse import urlparse

inspector = inspect(SessionLocal().get_bind())
tables = inspector.get_table_names()
Expand All @@ -29,9 +30,10 @@
finally:
db.close()

parsed = urlparse(FRONTEND_URL)
app.add_middleware(
CORSMiddleware,
allow_origins=[FRONTEND_URL, "http://localhost:5173"],
allow_origins=[f'{parsed.scheme}://{parsed.netloc}', "http://localhost:5173"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down

0 comments on commit b413e11

Please sign in to comment.