mirror of
https://github.com/KohakuBlueleaf/KohakuHub.git
synced 2026-03-11 17:34:08 -05:00
16 lines
462 B
JavaScript
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);
|
|
}
|