From 22e947838955426beacb3baf81acf0c5bea9a9da Mon Sep 17 00:00:00 2001 From: admin <1297598740@qq.com> Date: Mon, 26 Jan 2026 15:29:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C=E3=80=81=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E3=80=81=E4=BB=A4=E7=89=8C=E7=AE=A1=E7=90=86=E3=80=81GitHub=20?= =?UTF-8?q?OAuth=E5=8F=8A=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/authService.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/authService.ts b/src/services/authService.ts index a6d3c91..09c02a1 100644 --- a/src/services/authService.ts +++ b/src/services/authService.ts @@ -141,7 +141,16 @@ export function getGitHubLoginUrl(state?: string): string { : '/api/v1'; console.log('[Auth] Generating GitHub URL with base:', baseUrl); - const url = new URL(`${baseUrl}/auth/github`); + + // 处理相对路径问题:URL构造函数依然需要完整的 base 才能处理相对路径 + let fullUrlString; + if (baseUrl.startsWith('/')) { + fullUrlString = `${window.location.origin}${baseUrl}/auth/github`; + } else { + fullUrlString = `${baseUrl}/auth/github`; + } + + const url = new URL(fullUrlString); if (state) { url.searchParams.append('state', state); }