Files
KohakuHub/functions/_proxy.js
2025-10-04 12:17:52 +08:00

16 lines
462 B
JavaScript

/**
* Shared proxy handler for KohakuHub API requests
* Used by all Cloudflare Pages Functions to proxy requests to the backend API
*/
import { proxyToVps, handleOptions } from './_utils.js';
export async function proxyToAPI(context, stripPrefix) {
// Handle CORS preflight
if (context.request.method === 'OPTIONS') {
return handleOptions(context.request);
}
// Proxy to VPS API
return proxyToVps(context.request, context.env, stripPrefix);
}