forked from 77media/video-flow
updates google login
This commit is contained in:
parent
5b7cc99306
commit
e02a52dfff
@ -162,14 +162,14 @@ function getRedirectUri(request: NextRequest): string {
|
||||
const protocol = request.headers.get('x-forwarded-proto') || 'https';
|
||||
|
||||
if (host.includes('localhost') || host.includes('127.0.0.1')) {
|
||||
return `${protocol}://${host}/users/oauth/callback`;
|
||||
return `${protocol}://${host}/api/auth/google/callback`;
|
||||
} else if (host.includes('movieflow.net')) {
|
||||
return 'https://www.movieflow.net/users/oauth/callback';
|
||||
return 'https://www.movieflow.net/api/auth/google/callback';
|
||||
} else if (host.includes('movieflow.ai')) {
|
||||
return 'https://www.movieflow.ai/users/oauth/callback';
|
||||
return 'https://www.movieflow.ai/api/auth/google/callback';
|
||||
} else {
|
||||
// 默认使用生产环境
|
||||
return 'https://www.movieflow.ai/users/oauth/callback';
|
||||
return 'https://www.movieflow.ai/api/auth/google/callback';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ async function simulateUserJourney() {
|
||||
// 模拟环境检测
|
||||
const hostname = 'www.movieflow.net';
|
||||
const isDevEnv = hostname.includes('movieflow.net');
|
||||
const redirectUri = isDevEnv ? 'https://www.movieflow.net/users/oauth/callback' : 'https://www.movieflow.ai/users/oauth/callback';
|
||||
const redirectUri = isDevEnv ? 'https://www.movieflow.net/api/auth/google/callback' : 'https://www.movieflow.ai/api/auth/google/callback';
|
||||
|
||||
logSuccess(`🔄 构建授权URL,redirect_uri: ${redirectUri}`);
|
||||
journey.push({
|
||||
@ -140,11 +140,11 @@ async function simulateUserJourney() {
|
||||
});
|
||||
|
||||
// 步骤4: Google重定向回应用
|
||||
logInfo('🔄 Google重定向到 /users/oauth/callback?code=xxx&state=xxx');
|
||||
logInfo('🔄 Google重定向到 /api/auth/google/callback?code=xxx&state=xxx');
|
||||
journey.push({
|
||||
step: 4,
|
||||
action: 'Google重定向回调',
|
||||
callbackUrl: '/users/oauth/callback',
|
||||
callbackUrl: '/api/auth/google/callback',
|
||||
status: 'success'
|
||||
});
|
||||
|
||||
@ -203,9 +203,9 @@ async function checkPotentialIssues() {
|
||||
// 2. Google Console配置检查
|
||||
logInfo('需要在Google Console中配置以下redirect_uri:');
|
||||
const redirectUris = [
|
||||
'https://www.movieflow.net/users/oauth/callback',
|
||||
'https://www.movieflow.ai/users/oauth/callback',
|
||||
'http://localhost:3000/users/oauth/callback'
|
||||
'https://www.movieflow.net/api/auth/google/callback',
|
||||
'https://www.movieflow.ai/api/auth/google/callback',
|
||||
'http://localhost:3000/api/auth/google/callback'
|
||||
];
|
||||
|
||||
redirectUris.forEach(uri => {
|
||||
|
||||
@ -85,7 +85,7 @@ async function simulateCompleteOAuthFlow() {
|
||||
|
||||
let redirectUri;
|
||||
if (isDevEnv) {
|
||||
redirectUri = 'https://www.movieflow.net/users/oauth/callback';
|
||||
redirectUri = 'https://www.movieflow.net/api/auth/google/callback';
|
||||
}
|
||||
|
||||
logSuccess(`环境检测: ${hostname} → DevEnv: ${isDevEnv}`);
|
||||
@ -270,7 +270,7 @@ async function simulateCompleteOAuthFlow() {
|
||||
code: mockAuthCode,
|
||||
client_id: CONFIG.GOOGLE_CLIENT_ID,
|
||||
client_secret: CONFIG.GOOGLE_CLIENT_SECRET,
|
||||
redirect_uri: 'https://www.movieflow.net/users/oauth/callback',
|
||||
redirect_uri: 'https://www.movieflow.net/api/auth/google/callback',
|
||||
grant_type: 'authorization_code',
|
||||
});
|
||||
|
||||
|
||||
@ -253,14 +253,14 @@ export const signInWithGoogle = async (inviteCode?: string): Promise<void> => {
|
||||
|
||||
let redirectUri;
|
||||
if (isLocalhost) {
|
||||
redirectUri = `${window.location.origin}/users/oauth/callback`;
|
||||
redirectUri = `${window.location.origin}/api/auth/google/callback`;
|
||||
} else if (isDevEnv) {
|
||||
redirectUri = 'https://www.movieflow.net/users/oauth/callback'; // 修正:指向正确的Next.js页面路由
|
||||
redirectUri = 'https://www.movieflow.net/api/auth/google/callback'; // 指向正确的API端点
|
||||
} else if (isProdEnv) {
|
||||
redirectUri = 'https://www.movieflow.ai/users/oauth/callback'; // 修正:指向正确的Next.js页面路由
|
||||
redirectUri = 'https://www.movieflow.ai/api/auth/google/callback'; // 指向正确的API端点
|
||||
} else {
|
||||
// 默认使用生产环境
|
||||
redirectUri = 'https://www.movieflow.ai/users/oauth/callback'; // 修正:指向正确的Next.js页面路由
|
||||
redirectUri = 'https://www.movieflow.ai/api/auth/google/callback'; // 指向正确的API端点
|
||||
}
|
||||
|
||||
console.log('使用的redirect_uri:', redirectUri);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user