mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): hide unhandled error messages in prod (#28156)
This commit is contained in:
parent
4846dbf6f8
commit
42ef331816
@ -115,7 +115,13 @@ function normalizeError (error: any) {
|
||||
// temp fix for https://github.com/unjs/nitro/issues/759
|
||||
// TODO: investigate vercel-edge not using unenv pollyfill
|
||||
const cwd = typeof process.cwd === 'function' ? process.cwd() : '/'
|
||||
const stack = ((error.stack as string) || '')
|
||||
|
||||
// Hide details of unhandled/fatal errors in production
|
||||
const hideDetails = !import.meta.dev && error.unhandled
|
||||
|
||||
const stack = hideDetails
|
||||
? []
|
||||
: ((error.stack as string) || '')
|
||||
.split('\n')
|
||||
.splice(1)
|
||||
.filter(line => line.includes('at '))
|
||||
@ -135,9 +141,8 @@ function normalizeError (error: any) {
|
||||
})
|
||||
|
||||
const statusCode = error.statusCode || 500
|
||||
const statusMessage =
|
||||
error.statusMessage ?? (statusCode === 404 ? 'Not Found' : '')
|
||||
const message = error.message || error.toString()
|
||||
const statusMessage = error.statusMessage ?? (statusCode === 404 ? 'Not Found' : '')
|
||||
const message = hideDetails ? 'internal server error' : (error.message || error.toString())
|
||||
|
||||
return {
|
||||
stack,
|
||||
|
Loading…
Reference in New Issue
Block a user