feat: 修复github认证
This commit is contained in:
@@ -134,7 +134,13 @@ export function logout(): void {
|
|||||||
* Validates: Requirements 13.1
|
* Validates: Requirements 13.1
|
||||||
*/
|
*/
|
||||||
export function getGitHubLoginUrl(state?: string): string {
|
export function getGitHubLoginUrl(state?: string): string {
|
||||||
const baseUrl = import.meta.env.VITE_API_BASE_URL || 'http://localhost:2612/api/v1';
|
// 强制修正:如果不是本地开发环境,必须使用相对路径
|
||||||
|
const isLocal = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
||||||
|
const baseUrl = isLocal
|
||||||
|
? (import.meta.env.VITE_API_BASE_URL || 'http://localhost:2612/api/v1')
|
||||||
|
: '/api/v1';
|
||||||
|
|
||||||
|
console.log('[Auth] Generating GitHub URL with base:', baseUrl);
|
||||||
const url = new URL(`${baseUrl}/auth/github`);
|
const url = new URL(`${baseUrl}/auth/github`);
|
||||||
if (state) {
|
if (state) {
|
||||||
url.searchParams.append('state', state);
|
url.searchParams.append('state', state);
|
||||||
|
|||||||
Reference in New Issue
Block a user