谷歌环境变量配置

This commit is contained in:
qikongjian 2025-09-21 12:37:34 +08:00
parent 8dd01254ea
commit e5759f5a6f
4 changed files with 16 additions and 24 deletions

View File

@ -4,4 +4,7 @@ NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com
NEXT_PUBLIC_CUT_URL = https://77.smartcut.py.qikongjian.com
# 失败率
NEXT_PUBLIC_ERROR_CONFIG = 0.1
NEXT_PUBLIC_ERROR_CONFIG = 0.1
# Google OAuth配置
NEXT_PUBLIC_GOOGLE_CLIENT_ID=847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com
NEXT_PUBLIC_GOOGLE_REDIRECT_URI=https://www.movieflow.net/api/auth/google/callback

View File

@ -6,9 +6,14 @@ NEXT_PUBLIC_CUT_URL = https://77.smartcut.py.qikongjian.com
# NEXT_PUBLIC_JAVA_URL = https://auth.movieflow.ai
# NEXT_PUBLIC_BASE_URL = https://api.video.movieflow.ai
# NEXT_PUBLIC_CUT_URL = https://smartcut.movieflow.ai
#NEXT_PUBLIC_GOOGLE_REDIRECT_URI=https://www.movieflow.ai/api/auth/google/callback
# 当前域名配置
NEXT_PUBLIC_FRONTEND_URL = https://www.movieflow.ai
# 失败率配置
NEXT_PUBLIC_ERROR_CONFIG = 0.2
# Google OAuth配置
NEXT_PUBLIC_GOOGLE_CLIENT_ID=847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com
NEXT_PUBLIC_GOOGLE_REDIRECT_URI=https://www.movieflow.net/api/auth/google/callback

View File

@ -87,8 +87,8 @@ export async function POST(request: NextRequest) {
});
// 第一步使用authorization code向Google换取access token和id_token
const googleClientId = '847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com';
const googleClientSecret = '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'; // 需要设置环境变量
const googleClientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || '847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com';
const googleClientSecret = process.env.GOOGLE_CLIENT_SECRET || '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';
if (!googleClientSecret) {
console.error('Google Client Secret未配置');

View File

@ -185,8 +185,8 @@ export const authFetch = async (url: string, options: RequestInit = {}) => {
// Google OAuth相关函数
// Google Client ID
const GOOGLE_CLIENT_ID = '847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com';
// Google Client ID - 从环境变量获取
const GOOGLE_CLIENT_ID = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || '847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com';
/**
* Google GSI SDK
@ -246,24 +246,8 @@ export const signInWithGoogle = async (inviteCode?: string): Promise<void> => {
nonce: nonce
};
// 根据环境确定正确的redirect_uri
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
const isDevEnv = window.location.hostname.includes('movieflow.net');
const isProdEnv = window.location.hostname.includes('movieflow.ai');
let redirectUri;
redirectUri = 'https://www.movieflow.net/api/auth/google/callback';
// if (isLocalhost) {
// // 本地开发环境:仍然使用本地地址,但后端会转发到测试环境处理
// redirectUri = `${window.location.origin}/api/auth/google/callback`;
// } else if (isDevEnv) {
// // 指向正确的API端点
// } else if (isProdEnv) {
// redirectUri = 'https://www.movieflow.ai/api/auth/google/callback'; // 指向正确的API端点
// } else {
// // 默认使用生产环境
// redirectUri = 'https://www.movieflow.ai/api/auth/google/callback'; // 指向正确的API端点
// }
// 根据环境变量确定redirect_uri
const redirectUri = process.env.NEXT_PUBLIC_GOOGLE_REDIRECT_URI || 'https://www.movieflow.ai/api/auth/google/callback';
console.log('使用的redirect_uri:', redirectUri);