`fetch` not working in Next.js API, the strangest issue I've encountered

I'm using t3 with pages router, and in one particular API call I'm trying to fetch a particular image and save it in my GCS bucket. The code has access to GCS bucket (confirmed) & the imageUrl is logged and tested, works perfectly fine. If you fetch it normally in browser console it works, if you fetch in reqbin it returns a 200. Not pasting entire code here but here's the important bit:
console.log('l222')
console.log(imageLink)
const response = await fetch(imageUrl);

if (!response.ok) {
console.error(`Failed to fetch image ${response.status}`)
throw new Error(`Failed to fetch image. Status: ${response.status}`)
}
console.log('l229')
console.log('l222')
console.log(imageLink)
const response = await fetch(imageUrl);

if (!response.ok) {
console.error(`Failed to fetch image ${response.status}`)
throw new Error(`Failed to fetch image. Status: ${response.status}`)
}
console.log('l229')
I am stumped as to why after the line const response = await fetch(imageUrl the code stops working ENTIRELY. Here's my server logs
No description
1 Reply
Mehul Sharma
Mehul SharmaOP12mo ago
Some more info: Hosted on vercel (pro) so there's no timeout, current function runs for 1.59s out of 20s limit. Tried it multiple times doesn't work. Fails BEFORE uploading to GCS so it's not a GCS issue. Happy to provide more context if needed. okay fyi this was a ME error.
Want results from more Discord servers?
Add your server