Open chandlervdw opened 11 months ago
Any updates here?
Edit by maintainers: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote đź‘Ť on the issue description or subscribe to the issue for updates. Thanks!
@chandlervdw how did you manage to solve this?
@chandlervdw how did you manage to solve this?
@Jdruwe I made a new fetch function that was specifically for generateStaticParams
that didn’t reference draftMode()
@chandlervdw how did you manage to solve this?
@Jdruwe I made a new fetch function that was specifically for
generateStaticParams
that didn’t referencedraftMode()
Yea, thanks I did the same in the end :)
Just encountered the same problem in Next.js 14.2, but the error message seems to be changed now:
Error: `draftMode` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context
This message is more helpful. However, it took me quite a while to realize it had to do with something happening in generateStaticParams
What is the improvement or update you wish to see?
Currently, when
draftMode()
is utilized directly or in a function reference withingenerateStaticParams
, the cryptic error message is as follow:It took me forever to figure out that it it was coming from calling a fetch() function that uses
draftMode()
from withingenerateStaticParams
. Either the messaging needs to be improved, ordraftMode().isEnabled
should be stubbed tofalse
within that context.Is there any context that might help us understand?
It would also be helpful to explain why
draftMode()
hasn't initialized when pre-rendering.Does the docs page already exist? Please link to it.
https://nextjs.org/docs/app/building-your-application/configuring/draft-mode