blomqma/next-rest-framework

Need for "force-dynamic"

markedwards opened this issue · 2 comments

I find that I have to add export const dynamic = 'force-dynamic'; boilerplate everywhere I use next-rest-framework. Is it possible to alleviate this? Could the library use unstable_noStore() internally, for instance?

Thanks, I can confirm that with app router when using the default nodejs runtime, the force-dynamic option is needed for the docs endpoint (docsRoute) because it reads the request headers directly from the original request object, but for the other routes defined with route this shouldn't be needed.

I have created a fix for this in v6.0.1 that reads the request headers from a cloned request object in the app router docs endpoint so explicitly using the force-dynamic caching strategy should no longer be needed.

Thanks, the issue I had previously when not declaring "force-dynamic" on endpoints seems to no longer be reproducible. However, I do see this warning at build time, when I omit the declarations:

TypeError: Cannot read properties of undefined (reading 'pathname')

Oddly it is only triggered by one of the endpoints, and it goes away if I set export const dynamic = 'force-dynamic'; there.