Skip to content

Commit

Permalink
Bypass authorization token for preflight requests
Browse files Browse the repository at this point in the history
Browsers should not send credentials in preflight requests irrespective of this setting.

Source: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#sending_a_request_with_credentials_included
  • Loading branch information
dulacp committed May 16, 2024
1 parent 973617a commit 875ea02
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ async def create_embedding(request: EmbeddingRequest, raw_request: Request):
@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:
Expand Down

0 comments on commit 875ea02

Please sign in to comment.