Next.js Discord

Discord Forum

Display dynamic error messages in the `error.js` file in production builds

Unanswered
nitestack posted this in #help-forum
Open in Discord
In dev builds, I can just throw an error in the server component and it will display the error.message as an h3 or something.
In production builds, it shows this error:

Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.


instead of something like

Error: Unauthorized!


How can I retrieve dynamic error messages and display it in the error.js file in production builds?

2 Replies

Yeah this is what I'd like to know as well, I've been asking this since last week but nobody answers so good luck to you lol
I checked and there isn't anything about this in de documentation other than the same message you get in the console, nobody asked about this apparently in google or at least last time I checked a couple of days ago, like no setting one could tweak to get the actual error so I'm absolutely lost. I started migrating my last error.js page to a client component since I couldn't figure it out so I really hope someone replies 🙌 🤞