load dotenv everywhere it's needed; postgresql pool pre ping
This commit is contained in:
@@ -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(",")]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user