Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

ERROR (payload): Error hitting revalidate route

default discord avatar
kappa_r2 years ago
2

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

  • default discord avatar
    marcusr51352 years ago

    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 :


    11:51:42] ERROR (payload): TypeError: fetch failed
     at Object.fetch (node:internal/deps/undici/undici:11457:11)


    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!!

  • default discord avatar
    ryanmearns2 years ago

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



    However, it seems ISR is quite buggy in the new app directory. Deployed to vercel I can get the home route "/" to revalidate but not any other page. But the other pages will revalidate when I run it on the root URL "/" but not the individual path like "about-us"

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.