fix(upload): send browser-like headers in from-url fetch (CDN 403s)
Publish container image / build-and-push (push) Canceled after 0s
Publish container image / build-and-push (push) Canceled after 0s
This commit is contained in:
@@ -286,7 +286,14 @@ function downloadImage(imageUrl, maxRedirects = 5) {
|
|||||||
const parsed = new URL(imageUrl);
|
const parsed = new URL(imageUrl);
|
||||||
const client = parsed.protocol === 'https:' ? https : http;
|
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
|
// Follow redirects up to maxRedirects times
|
||||||
if ([301, 302, 303, 307, 308].includes(response.statusCode) && response.headers.location) {
|
if ([301, 302, 303, 307, 308].includes(response.statusCode) && response.headers.location) {
|
||||||
if (maxRedirects <= 0) {
|
if (maxRedirects <= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user