Download relayer callbacks for proxying CORS-restricted downloads.
Provides a callback to proxy download requests through your application server
when direct browser access fails due to CORS restrictions (e.g., Google Drive).
IMPORTANT SECURITY REQUIREMENTS for your proxy endpoint:
MUST block requests to private/internal IPs (SSRF protection)
SHOULD NOT restrict domains (files can be hosted anywhere)
// SSRF Protection: Block private/internal IPs if (isIPv4(ip)) { const [a, b] = ip.split('.').map(Number); if (a === 10 || a === 127 || a === 0 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 169 && b === 254) || a >= 224) { // Also block multicast/reserved returnnewResponse('Private/internal addresses not allowed', { status:403 }); } }
// Proxy the request constresponse = awaitfetch(url, { redirect:'manual' });
Download relayer callbacks for proxying CORS-restricted downloads.
Provides a callback to proxy download requests through your application server when direct browser access fails due to CORS restrictions (e.g., Google Drive).
IMPORTANT SECURITY REQUIREMENTS for your proxy endpoint:
Example: Client-side implementation:
Example: Server-side proxy endpoint (Next.js):