添加nginx相关配置,首页系统概览添加用户id查询
This commit is contained in:
+110
-6
@@ -44,7 +44,7 @@ const configs: Record<string, ApiConfig> = {
|
||||
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb', // 需要替换为实际的Client Secret
|
||||
redirectUri: 'http://10.79.97.17/', // 回调地址
|
||||
redirectUri: 'http://10.79.97.17/callback', // 回调地址
|
||||
appId: 'idaasoauth2' // 应用ID,用于登出
|
||||
}
|
||||
},
|
||||
@@ -75,7 +75,8 @@ const configs: Record<string, ApiConfig> = {
|
||||
serverUrl: 'http://10.79.112.85', // IDaaS服务器地址
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb', // 需要替换为实际的Client Secret
|
||||
redirectUri: 'http://10.79.97.17/', // 回调地址
|
||||
redirectUri: 'http://10.79.97.17/callback', // 回调地址
|
||||
|
||||
appId: 'idaasoauth2' // 应用ID,用于登出
|
||||
}
|
||||
},
|
||||
@@ -95,12 +96,97 @@ const configs: Record<string, ApiConfig> = {
|
||||
}
|
||||
};
|
||||
|
||||
// 客户端特定配置 - 支持多客户端部署
|
||||
// 根据环境自动选择配置
|
||||
const getClientConfigs = (env: string): Record<string, Partial<ApiConfig>> => {
|
||||
if (env === 'development') {
|
||||
// 开发环境 - 本地nginx代理配置
|
||||
return {
|
||||
'client-a': {
|
||||
baseUrl: 'http://localhost:8001',
|
||||
uploadUrl: 'http://localhost:8001/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://localhost:8001/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
},
|
||||
'client-b': {
|
||||
baseUrl: 'http://localhost:8002',
|
||||
uploadUrl: 'http://localhost:8002/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://localhost:8002/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
},
|
||||
'client-c': {
|
||||
baseUrl: 'http://localhost:8003',
|
||||
uploadUrl: 'http://localhost:8003/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://localhost:8003/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// 生产环境 - 服务器配置
|
||||
return {
|
||||
'client-a': {
|
||||
baseUrl: 'http://10.79.97.17:51701',
|
||||
uploadUrl: 'http://10.79.97.17:51701/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://10.79.97.17:51701/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
},
|
||||
'client-b': {
|
||||
baseUrl: 'http://10.79.97.17:51702',
|
||||
uploadUrl: 'http://10.79.97.17:51702/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://10.79.97.17:51702/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
},
|
||||
'client-c': {
|
||||
baseUrl: 'http://10.79.97.17:51704',
|
||||
uploadUrl: 'http://10.79.97.17:51704/admin/documents',
|
||||
oauth: {
|
||||
serverUrl: 'http://10.79.112.85',
|
||||
clientId: '54d2a619fe5c81ae1250434c441fccccqMtKwh7H4fO',
|
||||
clientSecret: 'VYk1AC5XIJEfnEXwyq0u9JEY3fi3byCfSD58zANGeb',
|
||||
redirectUri: 'http://10.79.97.17:51704/callback',
|
||||
appId: 'idaasoauth2'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// 获取当前环境,默认为development
|
||||
const getCurrentEnvironment = (): string => {
|
||||
// 优先使用环境变量,然后使用 NODE_ENV
|
||||
return process.env.NEXT_PUBLIC_API_ENV || process.env.NODE_ENV || 'development';
|
||||
};
|
||||
|
||||
// 获取客户端ID
|
||||
const getClientId = (): string => {
|
||||
return process.env.CLIENT_ID || process.env.NEXT_PUBLIC_CLIENT_ID || 'main';
|
||||
};
|
||||
|
||||
// 从环境变量获取配置,如果环境变量不存在则使用默认配置
|
||||
const getConfigFromEnv = (defaultConfig: ApiConfig): ApiConfig => {
|
||||
return {
|
||||
@@ -117,17 +203,35 @@ const getConfigFromEnv = (defaultConfig: ApiConfig): ApiConfig => {
|
||||
};
|
||||
};
|
||||
|
||||
// 获取当前配置
|
||||
// 获取当前配置 - 支持客户端特定配置
|
||||
const getCurrentConfig = (): ApiConfig => {
|
||||
const env = getCurrentEnvironment();
|
||||
const clientId = getClientId();
|
||||
const defaultConfig = configs[env] || configs.development;
|
||||
|
||||
// 获取当前环境的客户端特定配置
|
||||
const clientConfigs = getClientConfigs(env);
|
||||
const clientConfig = clientConfigs[clientId];
|
||||
|
||||
// 合并默认配置和客户端特定配置
|
||||
let finalConfig = defaultConfig;
|
||||
if (clientConfig) {
|
||||
finalConfig = {
|
||||
...defaultConfig,
|
||||
...clientConfig,
|
||||
oauth: {
|
||||
...defaultConfig.oauth,
|
||||
...clientConfig.oauth
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 如果是浏览器环境,尝试从环境变量覆盖配置
|
||||
if (typeof window !== 'undefined' || process.env.NEXT_PUBLIC_API_BASE_URL) {
|
||||
return getConfigFromEnv(defaultConfig);
|
||||
return getConfigFromEnv(finalConfig);
|
||||
}
|
||||
|
||||
return defaultConfig;
|
||||
return finalConfig;
|
||||
};
|
||||
|
||||
// 导出当前环境的配置
|
||||
@@ -155,4 +259,4 @@ export const setEnvironment = (env: string): ApiConfig => {
|
||||
// environment: getCurrentEnvironment(),
|
||||
// config: apiConfig
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user