load dotenv everywhere it's needed; postgresql pool pre ping

This commit is contained in:
2026-05-20 02:21:22 +08:00
parent c68d88b8c1
commit d54aeaa61a
7 changed files with 23 additions and 4 deletions
+2
View File
@@ -3,6 +3,7 @@ from fastapi import FastAPI, Depends, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from strawberry import Schema
from strawberry.fastapi import GraphQLRouter
from dotenv import load_dotenv
from auth import router as auth_router, get_user_by_id, get_current_user
@@ -22,6 +23,7 @@ Base.metadata.create_all(bind=engine)
app = FastAPI()
# 获取环境变量字符串,并转成列表
load_dotenv()
origins_str = os.getenv("CORS_ORIGINS", "http://localhost:3000")
origins = [origin.strip() for origin in origins_str.split(",")]