Skip to content

Commit

Permalink
Fix CORS compatibility with OpenAI, vLLM, TGI, LMDeploy (#1373)
Browse files Browse the repository at this point in the history
Co-authored-by: Yineng Zhang <[email protected]>
  • Loading branch information
josephrocca and zhyncs authored Sep 10, 2024
1 parent e72275c commit dff2860
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/sglang/srt/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import uvicorn
import uvloop
from fastapi import FastAPI, File, Form, Request, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, Response, StreamingResponse

from sglang.lang.backend.runtime_endpoint import RuntimeEndpoint
Expand Down Expand Up @@ -93,6 +94,14 @@
app = FastAPI()
tokenizer_manager = None

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)


@app.get("/health")
async def health() -> Response:
Expand Down

0 comments on commit dff2860

Please sign in to comment.