thomas commited on
Commit ·
f68f72a
1
Parent(s): ac40df2
bugfix(#82): cors error fixed
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from Brain.src.firebase.firebase import initialize_app
|
| 2 |
-
from fastapi import
|
|
|
|
| 3 |
import uvicorn
|
| 4 |
|
| 5 |
from Brain.src.router.browser_router import construct_blueprint_browser_api
|
|
@@ -10,6 +11,16 @@ initialize_app()
|
|
| 10 |
from Brain.src.router.api import construct_blueprint_api
|
| 11 |
|
| 12 |
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
app.include_router(construct_blueprint_api(), tags=["ai_app"])
|
| 14 |
app.include_router(
|
| 15 |
construct_blueprint_browser_api(), prefix="/browser", tags=["ai_browser"]
|
|
|
|
| 1 |
from Brain.src.firebase.firebase import initialize_app
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
import uvicorn
|
| 5 |
|
| 6 |
from Brain.src.router.browser_router import construct_blueprint_browser_api
|
|
|
|
| 11 |
from Brain.src.router.api import construct_blueprint_api
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
+
# Set up CORS middleware
|
| 15 |
+
app.add_middleware(
|
| 16 |
+
CORSMiddleware,
|
| 17 |
+
allow_origins=["*"], # Allow all origins (domains)
|
| 18 |
+
allow_credentials=True,
|
| 19 |
+
allow_methods=["*"], # Allow all methods (GET, POST, PUT, DELETE, OPTIONS, etc.)
|
| 20 |
+
allow_headers=["*"], # Allow all headers
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Set up routers
|
| 24 |
app.include_router(construct_blueprint_api(), tags=["ai_app"])
|
| 25 |
app.include_router(
|
| 26 |
construct_blueprint_browser_api(), prefix="/browser", tags=["ai_browser"]
|