TypeError: fetch failed during Pages Build

I have an eleventy site and during build, I reach out to one of my API's to fetch some data. All other APIs or URL seem to work but not the one in my zone. So my pages is on the root doman: example.com and I have a A Record setup pointing to an IP address of the remote server (not a worker): api.example.com The build process tries to make a request to api.example.com and it fails without meaningful errors. Does not matter if the api subdomain is proxied or DNS only, it fails either way
[11ty] Eleventy Error (CLI):
15:11:11.918 [11ty] 1. Error in your Eleventy config file 'eleventy.config.js'. (via EleventyConfigError)
15:11:11.918 [11ty] 2. fetch failed (via TypeError)
15:11:11.918 [11ty]
15:11:11.919 [11ty] Original error stack trace: TypeError: fetch failed
15:11:11.919 [11ty] at node:internal/deps/undici/undici:13178:13
15:11:11.919 [11ty] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
15:11:11.919 [11ty] at async fetchPublicFigures (file:///opt/buildhome/repo/eleventy.config.js:230:20)
15:11:11.919 [11ty] at async default (file:///opt/buildhome/repo/eleventy.config.js:516:27)
[11ty] Eleventy Error (CLI):
15:11:11.918 [11ty] 1. Error in your Eleventy config file 'eleventy.config.js'. (via EleventyConfigError)
15:11:11.918 [11ty] 2. fetch failed (via TypeError)
15:11:11.918 [11ty]
15:11:11.919 [11ty] Original error stack trace: TypeError: fetch failed
15:11:11.919 [11ty] at node:internal/deps/undici/undici:13178:13
15:11:11.919 [11ty] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
15:11:11.919 [11ty] at async fetchPublicFigures (file:///opt/buildhome/repo/eleventy.config.js:230:20)
15:11:11.919 [11ty] at async default (file:///opt/buildhome/repo/eleventy.config.js:516:27)
I simplified my code to make a simple GET request, but no luck. Still errors out.
try {
const response = await fetch('https://api.example.com/login');
console.log('CMS Fetch API test successful:', response.status === 200);
return true;
} catch (error) {
console.error('Fetch API test failed:', error.message);
return false;
}
try {
const response = await fetch('https://api.example.com/login');
console.log('CMS Fetch API test successful:', response.status === 200);
return true;
} catch (error) {
console.error('Fetch API test failed:', error.message);
return false;
}
Works with google.com or any other website except that's managed by cloudflare DNS
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server