diff --git a/src/shared/api/account.ts b/src/shared/api/account.ts index ad583e8..578abe2 100644 --- a/src/shared/api/account.ts +++ b/src/shared/api/account.ts @@ -16,8 +16,7 @@ const getBackendUrl = () => { } else { // 生产环境:使用绝对 URL const backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com' - // 确保 URL 不以 /dashboard 结尾(API 路径应该直接在根路径下) - return backendUrl.replace(/\/dashboard\/?$/, '') + return backendUrl } } diff --git a/src/shared/api/oauth2.ts b/src/shared/api/oauth2.ts index 3d050e8..47b5140 100644 --- a/src/shared/api/oauth2.ts +++ b/src/shared/api/oauth2.ts @@ -18,12 +18,7 @@ import { // 从环境变量或配置获取 OAuth2 配置 const getOAuth2Config = () => { // 从环境变量或配置中获取 - let backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com' - - // 确保 URL 不以 /dashboard 结尾(API 路径应该直接在根路径下) - // 如果用户设置了 /dashboard,自动移除 - backendUrl = backendUrl.replace(/\/dashboard\/?$/, '') - + const backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com' const clientId = import.meta.env.VITE_OAUTH2_CLIENT_ID || 'i679osfadt' const redirectUri = `${window.location.origin}/oauth/callback` @@ -80,7 +75,6 @@ export async function getAuthorizationUrl(state?: string): Promise { ...(state && { state }) }) - // 确保 API 路径正确(不应该包含 /dashboard) const apiPath = '/api/action/jingrow.integrations.oauth2.authorize' const authUrl = `${config.backendUrl}${apiPath}?${params.toString()}` @@ -216,7 +210,6 @@ export async function refreshAccessToken(): Promise { * 撤销 token */ export async function revokeToken(token?: string, tokenTypeHint: 'access_token' | 'refresh_token' = 'access_token'): Promise { - const config = getOAuth2Config() const tokenToRevoke = token || (tokenTypeHint === 'access_token' ? getAccessToken() : getRefreshToken()) if (!tokenToRevoke) { @@ -254,7 +247,6 @@ export async function revokeToken(token?: string, tokenTypeHint: 'access_token' * 获取用户信息(OpenID Connect userinfo) */ export async function getUserInfo(): Promise { - const config = getOAuth2Config() const accessToken = getAccessToken() if (!accessToken) {