Next.js Discord

Discord Forum

Prevent Next from hiding error message in Production build

Unanswered
Bakharwal dog posted this in #help-forum
Open in Discord
Avatar
Bakharwal dogOP
Is there a way to prevent next from hiding the error message in production build? I want to expose it to the user.
Today in prod i'm getting:
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.

17 Replies

try {
  return ...
} catch (error) {
  console.error(error)
  return <ErrorUI msg={error instanceof Error ? error.message : "Unkonwn Server Error Occurred"}/>
}
Avatar
Bakharwal dogOP
I am catching the error , it still seems like next is masking it for some reason
cc @Alfonsus Ardani
Avatar
@Bakharwal dog cc <@194128415954173952>
Avatar
hmm thats weird, let me try it in a moment (thanks for the CC, but you can just reply my message)
Avatar
Bakharwal dogOP
any news? 😄
build succesfull, errror successfuully caught
Avatar
Bakharwal dogOP
in localhost, what about a production build?
Avatar
Bakharwal dogOP
interesting
can you try to export a function that does it for you in another file, where in the begining of the file there is use server ?
Avatar
can you help me with that? wdym?
Avatar
Bakharwal dogOP
the try catch part, put it in a function in another file and put use server at the top
you should be able to test it yourself
Avatar
Bakharwal dogOP
thanks!