llamaindex cors middleware
This commit is contained in:
@@ -8,6 +8,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
@@ -41,6 +42,15 @@ setup_logging()
|
|||||||
|
|
||||||
app = FastAPI(title="LlamaIndex RAG API", version="1.0.0")
|
app = FastAPI(title="LlamaIndex RAG API", version="1.0.0")
|
||||||
|
|
||||||
|
# Add CORS middleware
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["*"], # In production, configure this properly
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestQueryRequest(BaseModel):
|
class TestQueryRequest(BaseModel):
|
||||||
query: str = Field(..., min_length=1, description="User query text")
|
query: str = Field(..., min_length=1, description="User query text")
|
||||||
|
|||||||
Reference in New Issue
Block a user