fixed version control heatmap and activity
This commit is contained in:
34
app/api/gitea/[...path]/route.ts
Normal file
34
app/api/gitea/[...path]/route.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const GITEA_URL = process.env.GITEA_URL;
|
||||
|
||||
if (!GITEA_URL) {
|
||||
throw new Error('GITEA_URL is not set (check .env.local)');
|
||||
}
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
ctx: { params: Promise<{ path: string[] }> }
|
||||
) {
|
||||
const { path } = await ctx.params;
|
||||
const search = req.nextUrl.search || '';
|
||||
const url = `${GITEA_URL}/api/v1/${path.join('/')}${search}`;
|
||||
|
||||
const upstream = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
cache: 'no-store',
|
||||
});
|
||||
|
||||
const body = await upstream.text();
|
||||
|
||||
return new NextResponse(body, {
|
||||
status: upstream.status,
|
||||
headers: {
|
||||
'Content-Type':
|
||||
upstream.headers.get('content-type') || 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user