forked from 77media/video-flow
接口路径
This commit is contained in:
parent
0f2cead1c5
commit
d6cb6e0611
@ -6,8 +6,13 @@ import type { OAuthCallbackParams } from '@/app/types/google-oauth';
|
||||
* 处理从Google OAuth返回的授权码,完成用户认证
|
||||
*/
|
||||
export async function POST(request: NextRequest) {
|
||||
console.log('🎯 Google OAuth Callback API 被调用');
|
||||
console.log('📍 Request URL:', request.url);
|
||||
console.log('📍 Request method:', request.method);
|
||||
|
||||
try {
|
||||
const body = await request.json();
|
||||
console.log('📦 Request body:', body);
|
||||
const { code, state, inviteCode } = body;
|
||||
|
||||
// 验证必需参数
|
||||
@ -21,49 +26,8 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// 开发模式:使用测试环境的OAuth处理
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
const useTestEnv = isDevelopment; // 开发环境默认使用测试环境
|
||||
|
||||
if (useTestEnv) {
|
||||
console.log('🧪 开发模式:使用模拟OAuth响应');
|
||||
|
||||
// 解析state参数获取origin信息
|
||||
let stateData: any = {};
|
||||
try {
|
||||
stateData = JSON.parse(state);
|
||||
} catch (e) {
|
||||
console.warn('无法解析state参数:', state);
|
||||
}
|
||||
|
||||
// 模拟成功的OAuth响应
|
||||
const mockResponse = {
|
||||
success: true,
|
||||
data: {
|
||||
token: 'dev-mock-token-' + Date.now(),
|
||||
user: {
|
||||
userId: 'dev-user-' + Math.random().toString(36).substr(2, 9),
|
||||
userName: 'Development User',
|
||||
name: 'Dev User',
|
||||
email: 'dev@movieflow.com',
|
||||
authType: 'GOOGLE',
|
||||
isNewUser: false
|
||||
},
|
||||
userInfo: {
|
||||
userId: 'dev-user-' + Math.random().toString(36).substr(2, 9),
|
||||
userName: 'Development User',
|
||||
name: 'Dev User',
|
||||
email: 'dev@movieflow.com',
|
||||
authType: 'GOOGLE',
|
||||
isNewUser: false
|
||||
},
|
||||
message: 'Development mode - Google authentication simulated'
|
||||
}
|
||||
};
|
||||
|
||||
console.log('返回模拟OAuth响应:', mockResponse);
|
||||
return NextResponse.json(mockResponse);
|
||||
}
|
||||
// 移除开发模式模拟,始终调用真实接口
|
||||
console.log('🚀 开始处理Google OAuth回调,调用真实接口');
|
||||
|
||||
// 解析state参数
|
||||
let stateData: any = {};
|
||||
@ -91,6 +55,8 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
// 第二步:调用Java验证接口(只验证不创建用户)
|
||||
const javaBaseUrl = process.env.NEXT_PUBLIC_JAVA_URL || 'https://auth.test.movieflow.ai';
|
||||
console.log('🔧 环境变量 NEXT_PUBLIC_JAVA_URL:', process.env.NEXT_PUBLIC_JAVA_URL);
|
||||
console.log('🔧 最终使用的 javaBaseUrl:', javaBaseUrl);
|
||||
console.log('开始调用Java验证接口:', javaBaseUrl);
|
||||
|
||||
const verifyResponse = await fetch(`${javaBaseUrl}/api/auth/google/callback`, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user