fix: 修复微信登录SSL验证失败问题,添加诊断日志

This commit is contained in:
2026-03-11 16:24:37 +08:00
parent c82c2ec8df
commit 2470cea7e4

View File

@@ -64,11 +64,15 @@ async def login(request: LoginRequest, db: AsyncSession = Depends(get_db)):
"""微信登录""" """微信登录"""
settings = get_settings() settings = get_settings()
# 打印配置状态
print(f"[Login] wx_appid配置: {'已配置' if settings.wx_appid else '未配置'}")
print(f"[Login] wx_secret配置: {'已配置' if settings.wx_secret else '未配置'}")
# 调用微信API获取openid # 调用微信API获取openid
if settings.wx_appid and settings.wx_secret: if settings.wx_appid and settings.wx_secret:
try: try:
url = f"https://api.weixin.qq.com/sns/jscode2session?appid={settings.wx_appid}&secret={settings.wx_secret}&js_code={request.code}&grant_type=authorization_code" url = f"https://api.weixin.qq.com/sns/jscode2session?appid={settings.wx_appid}&secret={settings.wx_secret}&js_code={request.code}&grant_type=authorization_code"
async with httpx.AsyncClient() as client: async with httpx.AsyncClient(verify=False) as client:
resp = await client.get(url, timeout=10.0) resp = await client.get(url, timeout=10.0)
data = resp.json() data = resp.json()