#ERROR (payload): Error hitting revalidate route

5 messages · Page 1 of 1 (latest)

polar robin
#

I have an api route in my next.js pages app (api/revalidate) for on demand revalidation of the data, and I have set a afterChange hook in a payload collection like this (https://github.com/payloadcms/website-cms/blob/main/src/utilities/regeneratePage.ts).

When my next.js app is on dev server everything works, but when I build and serve the app it don't.
On the build I can go to the url for the revalidation and everything works fine, but for some reason payload can't.

Can someone help me? Thanks

hazy spoke
#

I've just hit the same error. It's not on my NextJS FE as I can revalidate with Postman. Its some issue on the Payload side. Could be CORS or Node version maybe (18.16). My error from the payload logs is :

 at Object.fetch (node:internal/deps/undici/undici:11457:11)```
hazy spoke
#

In my case it was a redirect on the front end URL that broke fetch (I didn't have redirect:follow set). I changed the URL and its working now.

#

The error message wasn't very helpful!!

inner cypress
#

I found this was a bug with the new fetch module in node. Going to node version 16 fixed this.