Unverified Commit 9216b9cc authored by Pierre Dulac's avatar Pierre Dulac Committed by GitHub
Browse files

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

parent 5e0391c0
...@@ -154,6 +154,8 @@ if __name__ == "__main__": ...@@ -154,6 +154,8 @@ if __name__ == "__main__":
@app.middleware("http") @app.middleware("http")
async def authentication(request: Request, call_next): async def authentication(request: Request, call_next):
root_path = "" if args.root_path is None else args.root_path 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"): if not request.url.path.startswith(f"{root_path}/v1"):
return await call_next(request) return await call_next(request)
if request.headers.get("Authorization") != "Bearer " + token: if request.headers.get("Authorization") != "Bearer " + token:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment