修复:延迟 Better Auth 初始化至运行时
此更新将 Better Auth 的初始化从模块导入时延迟到运行时,解决了生产构建中因缺少 `BETTER_AUTH_SECRET` 而导致的阻塞问题,同时保持生产环境下的运行时验证功能。
概述
延迟 Better Auth 初始化至运行时,而非模块导入时。
解除生产构建中因未提供 `BETTER_AUTH_SECRET` 而导致的阻塞。
保持生产运行时验证在认证实际使用时有效。
风险
风险等级为低至中。
涉及认证引导时序调整,但保持相同的 Better Auth 配置和请求时行为。
回滚
如需恢复急切的 Better Auth 初始化,可回滚此 PR。
测试日志
- cd /Users/xgjj/Desktop/AFM/product-code/frontend/web && ./node_modules/.bin/vitest run tests/unit/auth-server-config.spec.ts tests/unit/account-logout-route.spec.ts tests/unit/account-routes.spec.ts tests/unit/project-access.spec.ts
- cd /Users/xgjj/Desktop/AFM/product-code/frontend/web && NODE_ENV=production BETTER_AUTH_SECRET='' npm run build
- cd /Users/xgjj/Desktop/AFM/product-code/frontend/web && npm run typecheck
- cd /Users/xgjj/Desktop/AFM && npm run dev:flow