Skip to content

Commit b5a16e6

Browse files
committed
Allow CORS
1 parent 31c1d1a commit b5a16e6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

DocsManager/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from fastapi import FastAPI
3+
from fastapi.middleware.cors import CORSMiddleware
34

45
from app.api.routes import admin, base
56
from app.core.db_connection import init_db
@@ -14,6 +15,15 @@
1415

1516
app = FastAPI(title="Docs Manager API", version="0.1.0")
1617

18+
# Configure CORS - Allow any localhost or 127.0.0.1 with any port
19+
app.add_middleware(
20+
CORSMiddleware,
21+
allow_origin_regex=r"https?://(localhost|127\.0\.0\.1)(:\d+)?",
22+
allow_credentials=True,
23+
allow_methods=["*"], # Includes OPTIONS
24+
allow_headers=["*"],
25+
)
26+
1727
# Include routers
1828
app.include_router(base.router)
1929
app.include_router(admin.router)

RAGManager/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import threading
33

44
from fastapi import FastAPI
5+
from fastapi.middleware.cors import CORSMiddleware
56
from app.api.routes.chatMessage import router as chat_router
67
from app.api.routes import router as api_router
78
from app.api.routes.base import router as base_router
@@ -16,6 +17,15 @@
1617

1718
app = FastAPI(title="RAG Manager API", version="0.1.0")
1819

20+
# Configure CORS - Allow any localhost or 127.0.0.1 with any port
21+
app.add_middleware(
22+
CORSMiddleware,
23+
allow_origin_regex=r"https?://(localhost|127\.0\.0\.1)(:\d+)?",
24+
allow_credentials=True,
25+
allow_methods=["*"], # Includes OPTIONS
26+
allow_headers=["*"],
27+
)
28+
1929
# Global (non-versioned) routes
2030
app.include_router(base_router)
2131

0 commit comments

Comments
 (0)