export default { async fetch(request, env) { const corsHeaders = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "POST, OPTIONS", "Access-Control-Allow-Headers": "Content-Type" }; if (request.method === "OPTIONS") { return new Response(null, { headers: corsHeaders }); } if (request.method !== "POST") { return new Response("OK", { status: 200, headers: corsHeaders }); } const body = await request.json(); const resp = await fetch("https://api.siliconflow.cn/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${env.SILICONFLOW_API_KEY}` }, body: JSON.stringify(body) }); return new Response(resp.body, { status: resp.status, headers: { ...corsHeaders, "Content-Type": "application/json" } }); } };