isr on demand revalidation with app directory not working
Answered
Sun bear posted this in #help-forum
Sun bearOP
I can't get a basic working ISR example working with the app directory. I'm not sure if this is a bug:
- https://github.com/jdgamble555/next-isr-test - Source Code
- https://next-isr-test-nine.vercel.app/ - Non Working Demo
Any help?
J
- https://github.com/jdgamble555/next-isr-test - Source Code
- https://next-isr-test-nine.vercel.app/ - Non Working Demo
Any help?
J
Answered by aardani
your /revalidate route needs to be set into dynamically computed as opposed to statically computed
7 Replies
your /revalidate route needs to be set into dynamically computed as opposed to statically computed
Answer
the thing is all route, including API handler are statically computed at build time.
You can easily turn it into dynamically computed by changing GET to POST, (which is why example uses POST not GET)
or
using any of the dynamic functions like cookies() or headers()
or
using any of the dynamic functions like cookies() or headers()
or
simply
simply
export const dynamic = 'force-dynamic'In your example, i changed the route handler from GET to POST and it works as expected
Sun bearOP
the force dynamic would make it dynamic every time... but chaning it to post definitely fixed the problem. Thanks!
they will need to be dynamic of course