[Bugfix] Bypass authorization API token for preflight requests (#4862)

This commit is contained in:
Pierre Dulac
2024-05-16 18:42:21 +02:00
committed by GitHub
parent 5e0391c040
commit 9216b9cc38

View File

@@ -154,6 +154,8 @@ if __name__ == "__main__":
@app.middleware("http")
async def authentication(request: Request, call_next):
root_path = "" if args.root_path is None else args.root_path
if request.method == "OPTIONS":
return await call_next(request)
if not request.url.path.startswith(f"{root_path}/v1"):
return await call_next(request)
if request.headers.get("Authorization") != "Bearer " + token: