update pay function
This commit is contained in:
@@ -22,16 +22,23 @@ export interface AuthInfo {
|
||||
*/
|
||||
export async function checkAuth(): Promise<AuthInfo> {
|
||||
try {
|
||||
// 使用硬编码的 URL 作为后备
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://49.232.185.254:5001';
|
||||
console.log('API URL:', apiUrl); // 调试日志
|
||||
// 根据访问方式决定 API URL
|
||||
const isProduction = typeof window !== 'undefined' && window.location.hostname === 'valuefrontier.cn';
|
||||
const apiUrl = isProduction
|
||||
? 'https://valuefrontier.cn' // 生产环境通过域名访问
|
||||
: (process.env.NEXT_PUBLIC_API_URL || 'http://localhost:5001'); // 开发环境
|
||||
|
||||
console.log('Auth check - API URL:', apiUrl, 'isProduction:', isProduction);
|
||||
|
||||
// 调用主应用的 session 检查接口
|
||||
const response = await fetch(`${apiUrl}/api/auth/session`, {
|
||||
method: 'GET',
|
||||
credentials: 'include', // 重要:携带 Cookie
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
// 对于同域请求,不需要额外的 CORS 配置
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user