INNER CODE UNIT · Python
__init__
SHAdd0WTAka/Zen-Ai-Pentest · api/main.py:552
def __init__(self, app):
self.app = app
async def __call__(self, scope, receive, send):
if scope["type"] == "http":
headers = dict(scope.get("headers", []))
origin = headers.get(b"origin", b"").decode() if b"origin" in headers else None
if origin and is_origin_allowed(origin):
scope["cors_origin"] = origin
await self.app(scope, receive, send)
app.add_middleware(
CORSMiddleware,
allow_origins=ALL_ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],