Skip to content

Commit

Permalink
Merge 04af21b into 5e66986
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzWeber0 authored Sep 26, 2024
2 parents 5e66986 + 04af21b commit c8d7993
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions backend/capellacollab/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,24 @@ async def handle_exceptions(request: fastapi.Request, exc: Exception):
in the case of exceptions.
https://github.com/encode/starlette/issues/1175
"""
origin = request.headers.get("origin")
response = responses.JSONResponse(
status_code=500, content={"body": "Internal Server Error"}
)

cors_middleware = cors.CORSMiddleware(
app=app,
allow_origins=ALLOW_ORIGINS,
allow_credentials=True,
allow_methods=["POST", "GET", "OPTIONS", "DELETE", "PUT", "PATCH"],
allow_headers=["*"],
)

response = responses.JSONResponse(
status_code=500, content={"body": "Internal Server Error"}
)
response.headers.update(cors_middleware.simple_headers)

if origin and cors_middleware.is_allowed_origin(origin=origin):
response.headers["Access-Control-Allow-Origin"] = origin
response.headers.add_vary_header("Origin")

return response


Expand Down

0 comments on commit c8d7993

Please sign in to comment.