Files
codex-bot 5051466692
Verify mini program and deploy preview / verify-deploy (push) Successful in 3m9s
feat: redesign typed bracket poster editor
2026-09-20 16:37:35 +08:00

30 lines
1.1 KiB
TypeScript

const API_BASE = process.env.API_INTERNAL_URL || 'http://pk-lab-api:8000';
async function forward(request: Request, context: { params: Promise<{ path: string[] }> }): Promise<Response> {
const { path } = await context.params;
const incoming = new URL(request.url);
const target = new URL(`/api/${path.join('/')}${incoming.search}`, API_BASE);
const headers = new Headers();
for (const name of ['authorization', 'content-type', 'accept']) {
const value = request.headers.get(name);
if (value) headers.set(name, value);
}
const response = await fetch(target, {
method: request.method,
headers,
body: ['GET', 'HEAD'].includes(request.method) ? undefined : await request.arrayBuffer(),
cache: 'no-store'
});
return new Response(response.body, {
status: response.status,
headers: { 'content-type': response.headers.get('content-type') || 'application/json' }
});
}
export const dynamic = 'force-dynamic';
export const GET = forward;
export const POST = forward;
export const PUT = forward;
export const PATCH = forward;
export const DELETE = forward;