blomqma/next-rest-framework

Error: Dynamic server usage

Opened this issue · 1 comments

This is somewhat related to #167, in the sense that this can be alleviated by specifying export const dynamic = "force-dynamic"; in next-rest-framework route handlers.

It looks like there's some call-stack issue where request.headers and request.url usage is generating Next build-time errors.

Error: Dynamic server usage: Route /api/internal couldn't be rendered statically because it used `request.headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
Next REST Framework encountered an error:
Error: Dynamic server usage: Route /api/internal/vertical-ids couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
Next REST Framework encountered an error:
Error: Dynamic server usage: Route /api/internal/brand-ids couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

Is this expected, like is there supposed to be a different way to build API routes with API key authentication that doesn't use headers?