1
0
mirror of https://github.com/nuxt/nuxt.git synced 2025-03-21 00:35:55 +00:00

fix(nuxt): normalise error url to pathname

This commit is contained in:
Daniel Roe 2025-03-19 15:53:49 +00:00
parent 8109d8625b
commit f4182359f9
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -28,6 +28,10 @@ export default <NitroErrorHandler> async function errorhandler (error, event, {
}
const errorObject = defaultRes.body as Pick<NonNullable<NuxtPayload['error']>, 'error' | 'statusCode' | 'statusMessage' | 'message' | 'stack'> & { url: string, data: any }
// remove proto/hostname/port from URL
const url = new URL(errorObject.url)
errorObject.url = url.pathname + url.search + url.hash
// add default server message
errorObject.message ||= 'Server Error'
delete defaultRes.headers['content-type'] // this would be set to application/json