Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Nextjs server side component not able to fetch data while running on cloud run

On my local server  side components are able to fetch data both in build and dev environment, but when i put it on GCP cloud run, its throw this error: 

 

 

 [TypeError: fetch failed] {"

 

 

Is it required to enable egress network/firewall rule?currently only ingress rule are there .
How can I fix this issue?

Solved Solved
0 3 547
1 ACCEPTED SOLUTION

hi @Hilda_Arteaga , thanks for the response,
What work in this case is changing the runtime environment,
previously it was set as 

export const runtime = "edge";

Changing it to 

export const runtime = "nodejs";

worked for me, and ok with that for now 

View solution in original post

3 REPLIES 3

Hi 

I found an alternative that could help.

You can explicitly tell cache.add() to bypass the HTTP cache by setting the cache mode of the Request to something like 'reload':

await openedCache.add(new Request(href, {cache: 'reload'}));

The downside of this approach is that you will end up with an extra network request that could have been avoided if you just had a valid entry in the HTTP cache to begin with. So I would go with the crossorigin="anonymous" instead.

I hope it helps, in the meantime we will continue exploring this, so please let us know how it goes 

hi @Hilda_Arteaga , thanks for the response,
What work in this case is changing the runtime environment,
previously it was set as 

export const runtime = "edge";

Changing it to 

export const runtime = "nodejs";

worked for me, and ok with that for now 

Hi @masnoonjunaid, it is great to read that you found a workaround that worked for you! We encourage you to mark one of the replies as an accepted solution so that anyone in the community facing a similar issue in the future can easily find the solution.

Thanks again for engaging, we deeply appreciate your contribution!