import { handleProxy, type ProxyEnv } from './functions/api/proxy' export interface Env extends ProxyEnv { ASSETS: { fetch: (request: Request) => Promise } } export default { async fetch(request: Request, env: Env): Promise { const url = new URL(request.url) // Handle /api/proxy CORS forwarding for DashScope (Qwen) & Volcengine Ark (Doubao) if (url.pathname === '/api/proxy') { if (request.method === 'POST' || request.method === 'GET') { return handleProxy({ request, env }) } return new Response(JSON.stringify({ error: { message: 'Method Not Allowed' } }), { status: 405, headers: { 'Content-Type': 'application/json; charset=utf-8' }, }) } // Fallback to static assets binding return env.ASSETS.fetch(request) }, }