Fix cors origin (#525)

This commit is contained in:
Nikhil Rao 2023-02-12 13:48:05 -08:00 committed by GitHub
parent fb9b8a8c83
commit f37540286c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,7 @@ class App(Base):
# Set up the API.
self.api = FastAPI()
self.add_cors(config.cors_allowed_origins)
self.add_cors()
self.add_default_endpoints()
# Set up CORS options.
@ -124,16 +124,10 @@ class App(Base):
# To test the server.
self.api.get(str(constants.Endpoint.PING))(ping)
def add_cors(self, allowed_origins: Optional[List[str]] = None):
"""Add CORS middleware to the app.
Args:
allowed_origins: A list of allowed origins.
"""
allowed_origins = allowed_origins or ["*"]
def add_cors(self):
"""Add CORS middleware to the app."""
self.api.add_middleware(
cors.CORSMiddleware,
allow_origins=allowed_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],