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

api/main.py: Add permissive CORS policy #435

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 12 additions & 4 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Request,
Form
)
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, PlainTextResponse
from fastapi.security import OAuth2PasswordRequestForm
from fastapi_pagination import add_pagination
Expand Down Expand Up @@ -704,11 +705,18 @@ async def put_regression(regression_id: str, regression: Regression,
]
)

versioned_app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
r-c-n marked this conversation as resolved.
Show resolved Hide resolved
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)


"""Workaround to use global exception handlers for versioned API.
The issue has already been reported here:
https://github.com/DeanWay/fastapi-versioning/issues/30
"""
# Workaround to use global exception handlers for versioned API.
# The issue has already been reported here:
# https://github.com/DeanWay/fastapi-versioning/issues/30
for sub_app in versioned_app.routes:
if hasattr(sub_app.app, "add_exception_handler"):
sub_app.app.add_exception_handler(
Expand Down
Loading