feat: pass GITEA_TOKEN to IDE containers + prewarm on project list load

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-19 16:13:09 -08:00
parent 97df21883b
commit 1ff58049c0
3 changed files with 46 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import { NextRequest, NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prewarmWorkspace } from '@/lib/cloud-run-workspace';
/**
* POST /api/projects/prewarm
* Body: { urls: string[] }
*
* Fires warm-up requests to Cloud Run workspace URLs so containers
* are running by the time the user clicks "Open IDE". Server-side
* to avoid CORS issues with run.app domains.
*/
export async function POST(req: NextRequest) {
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { urls } = await req.json() as { urls: string[] };
if (!Array.isArray(urls) || urls.length === 0) {
return NextResponse.json({ warmed: 0 });
}
// Fire all prewarm pings in parallel — intentionally not awaited
Promise.allSettled(urls.map(url => prewarmWorkspace(url))).catch(() => {});
return NextResponse.json({ warmed: urls.length });
}