Next.js Discord

Discord Forum

call revalidatePath from api route app router

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
Can i call revalidatPath(my path) from an api route? is there a way of doing so=

1 Reply

Bigheaded ant
Go figure, I've been trying to do the exact same thing today but all I get is Invariant: static generation store missing in revalidatePath

I'm calling it from an api route in the /pages directory to try to revalidate a path in the /app directory, not sure if that makes a difference.

The reason I'm doing it there is because we have a Contentful webhook set up to revalidate our pages, so we call res.revalidate() for any paths still on the /pages directory and revalidatePath() for any paths in the /app directory, but it fails with the error above.