mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:35:24 +02:00
fix: robust handling of Dropbox URLs in proxy with query params
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user