mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-14 18:54:46 +08:00
feat: add CORS setting for the backend application (#443)
* feat: add CORS setting for the backend application * fix the formate issue
This commit is contained in:
@@ -53,12 +53,17 @@ app = FastAPI(
|
||||
)
|
||||
|
||||
# Add CORS middleware
|
||||
# It's recommended to load the allowed origins from an environment variable
|
||||
# for better security and flexibility across different environments.
|
||||
allowed_origins_str = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000")
|
||||
allowed_origins = [origin.strip() for origin in allowed_origins_str.split(",")]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # Allows all origins
|
||||
allow_origins=allowed_origins, # Restrict to specific origins
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # Allows all methods
|
||||
allow_headers=["*"], # Allows all headers
|
||||
allow_methods=["GET", "POST"], # Be specific about allowed methods
|
||||
allow_headers=["Content-Type", "Authorization", "X-Requested-With"], # Be specific
|
||||
)
|
||||
|
||||
graph = build_graph_with_memory()
|
||||
|
||||
Reference in New Issue
Block a user