from fastapi.middleware.cors import CORSMiddleware from app.notification.webapi.config.site_settings import site_settings def register(app): app.debug = site_settings.DEBUG app.title = site_settings.NAME add_global_middleware(app) # This hook ensures that a connection is opened to handle any queries # generated by the request. @app.on_event("startup") def startup(): pass # This hook ensures that the connection is closed when we've finished # processing the request. @app.on_event("shutdown") def shutdown(): pass def add_global_middleware(app): app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], )