From 1df596c7497b115e0c614c73e37ecff2018d9dcc Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 17 Oct 2023 09:57:14 -0400 Subject: [PATCH] Added CORSMiddleware to allow Dug to make CORS requests. --- src/dug/server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dug/server.py b/src/dug/server.py index fde7e5a0..f7a8466a 100644 --- a/src/dug/server.py +++ b/src/dug/server.py @@ -3,6 +3,7 @@ import uvicorn from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from dug.config import Config from dug.core.async_search import Search from pydantic import BaseModel @@ -15,6 +16,13 @@ root_path=os.environ.get("ROOT_PATH", "/"), ) +APP.add_middleware( + CORSMiddleware, + allow_origins=['*'], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) class GetFromIndex(BaseModel): index: str = "concepts_index"