Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.kilocode
.kilocode

# Docs
Docs/

# AI
.claude/
.gemini/
.codex/
.cursor/
8 changes: 5 additions & 3 deletions app/api/auth/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { NextRequest, NextResponse } from 'next/server';

const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8008';
const FRONTEND_URL = process.env.NEXT_PUBLIC_FRONTEND_URL || 'http://localhost:3000';
import { getInternalApiBaseUrl } from '@/lib/apiBase';

/**
* OAuth 回调处理 (Linux.do SSO)
* 接收来自 OAuth 提供商的 code 和 state,
* 转发给后端 API 完成认证,然后重定向到前端
*/
export async function GET(request: NextRequest) {
const API_BASE_URL = getInternalApiBaseUrl();
const FRONTEND_URL = request.nextUrl.origin;

const searchParams = request.nextUrl.searchParams;
const code = searchParams.get('code');
const state = searchParams.get('state');
Expand Down Expand Up @@ -94,4 +96,4 @@ export async function GET(request: NextRequest) {
new URL('/auth?error=oauth_callback_failed', FRONTEND_URL)
);
}
}
}
8 changes: 5 additions & 3 deletions app/api/auth/github/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { NextRequest, NextResponse } from 'next/server';

const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8008';
const FRONTEND_URL = process.env.NEXT_PUBLIC_FRONTEND_URL || 'http://localhost:3000';
import { getInternalApiBaseUrl } from '@/lib/apiBase';

/**
* GitHub OAuth 回调处理
* 接收来自 GitHub 的 code 和 state,
* 转发给后端 API 完成认证,然后重定向到前端
*/
export async function GET(request: NextRequest) {
const API_BASE_URL = getInternalApiBaseUrl();
const FRONTEND_URL = request.nextUrl.origin;

const searchParams = request.nextUrl.searchParams;
const code = searchParams.get('code');
const state = searchParams.get('state');
Expand Down Expand Up @@ -101,4 +103,4 @@ export async function GET(request: NextRequest) {
new URL(`/auth?error=${encodeURIComponent(errorMessage)}`, FRONTEND_URL)
);
}
}
}
8 changes: 4 additions & 4 deletions app/dashboard/accounts/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function AccountsPage() {
const toasterRef = useRef<ToasterRef>(null);
const [accounts, setAccounts] = useState<Account[]>([]);
const [kiroAccounts, setKiroAccounts] = useState<KiroAccount[]>([]);
const [kiroBalances, setKiroBalances] = useState<Record<number, number>>({});
const [kiroBalances, setKiroBalances] = useState<Record<string, number>>({});
const [hasBeta, setHasBeta] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [isRefreshing, setIsRefreshing] = useState(false);
Expand Down Expand Up @@ -132,7 +132,7 @@ export default function AccountsPage() {
setKiroAccounts(kiroData);

// 加载每个Kiro账号的余额
const balances: Record<number, number> = {};
const balances: Record<string, number> = {};
await Promise.all(
kiroData.map(async (account) => {
try {
Expand Down Expand Up @@ -305,7 +305,7 @@ export default function AccountsPage() {
});
};

const handleDeleteKiro = (accountId: number) => {
const handleDeleteKiro = (accountId: string) => {
showConfirmDialog({
title: '删除账号',
description: '确定要删除这个 Kiro 账号吗?此操作无法撤销。',
Expand Down Expand Up @@ -1283,4 +1283,4 @@ export default function AccountsPage() {
</Dialog>
</div>
);
}
}
11 changes: 9 additions & 2 deletions app/dashboard/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MorphingSquare } from '@/components/ui/morphing-square';
import { cn } from '@/lib/utils';
import Toaster, { ToasterRef } from '@/components/ui/toast';
import { Badge as Badge1 } from '@/components/ui/badge-1';
import { getPublicApiBaseUrl } from '@/lib/apiBase';

export default function SettingsPage() {
const toasterRef = useRef<ToasterRef>(null);
Expand All @@ -37,7 +38,13 @@ export default function SettingsPage() {
const [selectedConfigType, setSelectedConfigType] = useState<'antigravity' | 'kiro'>('antigravity');
const [keyName, setKeyName] = useState('');

const apiEndpoint = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8008';
const [apiEndpoint, setApiEndpoint] = useState(() => getPublicApiBaseUrl());

useEffect(() => {
const base = getPublicApiBaseUrl();
if (/^https?:\/\//i.test(base)) return;
setApiEndpoint(`${window.location.origin}${base}`);
}, []);

const loadAPIKeys = async () => {
try {
Expand Down Expand Up @@ -565,4 +572,4 @@ export default function SettingsPage() {
</Dialog>
</div>
);
}
}
Loading