Skip to content

Commit

Permalink
cors fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cipher982 committed May 13, 2024
1 parent fa1c6d4 commit 5532738
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

frontend_port = os.environ.get("FRONTEND_PORT")
assert frontend_port is not None, "FRONTEND_PORT is not set"
print(f"Frontend port: {frontend_port}")


class SimulateRequest(BaseModel):
Expand Down Expand Up @@ -64,17 +65,15 @@ async def http_exception_handler(request: Request, exc: StarletteHTTPException):
)


class CustomCORSMiddleware(CORSMiddleware):
def is_allowed_origin(self, origin: str) -> bool:
if "http://marchmadness.drose.io" in origin or "http://localhost" in origin:
return True
return False


app.add_middleware(
CustomCORSMiddleware,
allow_origins=["*"],
allow_methods=["POST", "GET"],
CORSMiddleware,
allow_origins=[
"http://localhost",
"http://localhost:8080",
"http://marchmadness.drose.io:50001",
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

Expand Down

0 comments on commit 5532738

Please sign in to comment.