feat(api): add CORSMiddleware to api routing
This commit is contained in:
@@ -16,6 +16,7 @@ def build_app(api_bundle: ApiBundle) -> FastAPI:
|
||||
app.state.api = api_bundle
|
||||
app.mount("/static", StaticFiles(directory=root_path / "static/dist"))
|
||||
doc.mount(app)
|
||||
app.include_router(api.router)
|
||||
api.app.state.api = api_bundle
|
||||
app.mount("/api", api.app)
|
||||
app.include_router(view.router)
|
||||
return app
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
from fastapi import APIRouter
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from . import schedule, weather
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
router.include_router(weather.router)
|
||||
router.include_router(schedule.router)
|
||||
app = FastAPI(openapi_prefix="/api")
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
app.include_router(weather.router)
|
||||
app.include_router(schedule.router)
|
||||
|
||||
Reference in New Issue
Block a user