mirror of
https://github.com/Sosokker/HomieCare.git
synced 2025-12-18 17:54:04 +01:00
Enable CORS
This commit is contained in:
parent
df34b29cdc
commit
e581f00841
@ -1,6 +1,7 @@
|
||||
import uvicorn
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from routers import video, weather, prediction
|
||||
|
||||
|
||||
@ -14,6 +15,20 @@ app = FastAPI(
|
||||
lifespan=video.lifespan
|
||||
)
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
"http://localhost:5173",
|
||||
]
|
||||
|
||||
# Add CORS middleware to the FastAPI app
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["GET", "POST", "PUT", "DELETE"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(video.router, prefix="/camera")
|
||||
app.include_router(weather.router, prefix="/weather")
|
||||
app.include_router(prediction.router, prefix="/weather")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user