revalidate path does not work in route handlers
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
not sure if i'm going crazy, but i've tried so many methods trying to get revalidatePath to work from a route handler. I genuinely think it does not work / is broken. Even followed https://nextjs.org/docs/app/api-reference/functions/revalidatePath#route-handler and no luck. Is there any example of this working that I can follow? not sure what's wrong, it works fine in a server action
3 Replies
Netherland Dwarf
Hey ! Same here, i'm searching differences about a "rebuilding" behavior and a "revalidating" behavior.
Do you want to refresh an html file generated inside your .next build folder ? or is it about revalidating fetched data from a server side component ?
In fact, i'm able to "rebuild" the page at runtime with this segment config
Putting 0 to "revalidate" will switch the rendering of the page to dynamic but in my case i want to stay on static and trigger a granular rebuild but same as you :
I can clearly see the index.html file beeing regenerated with
Do you want to refresh an html file generated inside your .next build folder ? or is it about revalidating fetched data from a server side component ?
In fact, i'm able to "rebuild" the page at runtime with this segment config
export const revalidate = 1. Putting 0 to "revalidate" will switch the rendering of the page to dynamic but in my case i want to stay on static and trigger a granular rebuild but same as you :
I can clearly see the index.html file beeing regenerated with
export const revalidate = 1 but not with revalidatePath function. I tried to use it with "layout" and "page" secondary params as well.Headache here too
Maybe you can try to use
router.refresh() and be sure to use revalidation functions inside node.js or edge runtime