fix: resolve OAuth state cookie error - Add proper Cookie configuration with domain settings - Add domain extraction function for production environment - Update environment variables example

This commit is contained in:
theshy
2025-08-01 20:20:03 +08:00
parent da41306918
commit 2cd0ebda65
5 changed files with 162 additions and 13 deletions

View File

@ -7,6 +7,7 @@
### 常见错误原因
1. **NEXTAUTH_URL 格式错误**
- 包含多余的引号
- URL 格式不正确
- 协议不匹配http vs https
@ -94,6 +95,7 @@ AWS_S3_BUCKET="your-s3-bucket-name"
**原因**NEXTAUTH_URL 包含多余的引号或格式错误
**解决**
1. 检查 `.env.production` 文件
2. 确保 NEXTAUTH_URL 格式正确
3. 重启应用
@ -103,6 +105,7 @@ AWS_S3_BUCKET="your-s3-bucket-name"
**原因**Google OAuth 重定向 URI 未正确配置
**解决**
1. 在 Google Cloud Console 中添加正确的重定向 URI
2. 确保 URI 格式为:`https://your-domain.com/api/auth/callback/google`
@ -111,5 +114,6 @@ AWS_S3_BUCKET="your-s3-bucket-name"
**原因**Google OAuth 凭据错误
**解决**
1. 检查 GOOGLE_CLIENT_ID 和 GOOGLE_CLIENT_SECRET
2. 确保凭据与 Google Cloud Console 中的配置匹配
2. 确保凭据与 Google Cloud Console 中的配置匹配