From 599b0fa8e265bfa81603156f158dbbfafd02bf6c Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Fri, 16 Jan 2026 14:20:08 +0100 Subject: [PATCH] fix: robust handling of Dropbox URLs in proxy with query params --- api/dropbox/[...path].ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/dropbox/[...path].ts b/api/dropbox/[...path].ts index 1a98185..c53842b 100644 --- a/api/dropbox/[...path].ts +++ b/api/dropbox/[...path].ts @@ -27,9 +27,22 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { const requestPath = req.url || ''; const dropboxPath = requestPath.replace(/^\/api\/dropbox/, ''); // e.g. /scl/fi/xyz?dl=1 - const targetUrl = `https://www.dropbox.com${dropboxPath}`; + let targetUrl = `https://www.dropbox.com${dropboxPath}`; - console.log(`Proxying to: ${targetUrl}`); + // Ensure dl=1 is present to force download + if (targetUrl.includes('?')) { + if (!targetUrl.includes('dl=1')) { + targetUrl = targetUrl.replace('dl=0', 'dl=1'); + if (!targetUrl.includes('dl=1')) { + targetUrl += '&dl=1'; + } + } + } else { + targetUrl += '?dl=1'; + } + + console.log(`[Proxy] Incoming: ${req.url}`); + console.log(`[Proxy] Target: ${targetUrl}`); const response = await fetch(targetUrl);