diff --git a/backend/routes/upload.js b/backend/routes/upload.js index c3c865c..b0ce87e 100644 --- a/backend/routes/upload.js +++ b/backend/routes/upload.js @@ -286,7 +286,14 @@ function downloadImage(imageUrl, maxRedirects = 5) { const parsed = new URL(imageUrl); const client = parsed.protocol === 'https:' ? https : http; - client.get(imageUrl, { timeout: 30000 }, (response) => { + // Browser-like headers: many CDNs (film.ai, frameset, etc.) reject + // requests without UA/Referer with 403. + const requestHeaders = { + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36", + "Accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8", + "Referer": parsed.origin + "/", + }; + client.get(imageUrl, { timeout: 30000, headers: requestHeaders }, (response) => { // Follow redirects up to maxRedirects times if ([301, 302, 303, 307, 308].includes(response.statusCode) && response.headers.location) { if (maxRedirects <= 0) {