from __future__ import annotations import os from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.routers import auth, brand, reviews, faq, contact, seo, navigation, products, about, versions, guides, upload, export, site_images from app.routers.seasonal_products import autumn_router, winter_router from app.routers import winter_camp, destinations, blog, stories, news, pricing, qualifications, partners, calendar from app.routers import destinations_detail, gallery, courses, selector, customize app = FastAPI(title="呼籁旅行管理后台 API", version="1.0.0", redirect_slashes=False) # CORS - 根据环境区分 _cors_origins = ["https://admin.1814.love"] if os.getenv("ENV", "development") == "development": _cors_origins += ["http://localhost:5173", "http://localhost:3001"] app.add_middleware( CORSMiddleware, allow_origins=_cors_origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Register routers app.include_router(auth.router) app.include_router(brand.router) app.include_router(products.router) app.include_router(faq.router) app.include_router(reviews.router) app.include_router(about.router) app.include_router(contact.router) app.include_router(seo.router) app.include_router(navigation.router) app.include_router(versions.router) app.include_router(guides.router) app.include_router(upload.router) app.include_router(site_images.router) app.include_router(export.router) app.include_router(autumn_router) app.include_router(winter_router) app.include_router(winter_camp.router) app.include_router(destinations.router) app.include_router(blog.router) app.include_router(stories.router) app.include_router(news.router) app.include_router(pricing.router) app.include_router(qualifications.router) app.include_router(partners.router) app.include_router(calendar.router) app.include_router(destinations_detail.router) app.include_router(gallery.router) app.include_router(courses.router) app.include_router(selector.router) app.include_router(customize.router) @app.get("/api/health") def health_check(): return {"status": "ok", "service": "hulai-admin-api"}