8000 fix(nuxt): normalise error url to pathname · nuxt/nuxt@87b69c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 87b69c9

Browse files
committed
fix(nuxt): normalise error url to pathname
1 parent d5588db commit 87b69c9

File tree

1 file changed

+4
-0
lines changed
  • packages/nuxt/src/core/runtime/nitro/handlers

1 file changed

+4
-0
lines changed

packages/nuxt/src/core/runtime/nitro/handlers/error.ts

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export default <NitroErrorHandler> async function errorhandler (error, event, {
2929
}
3030

3131
const errorObject = defaultRes.body as Pick<NonNullable<NuxtPayload['error']>, 'error' | 'statusCode' | 'statusMessage' | 'message' | 'stack'> & { url: string, data: any }
32+
// remove proto/hostname/port from URL
33+
const url = new URL(errorObject.url)
34+
errorObject.url = url.pathname + url.search + url.hash
35+
// add default server message
3236
errorObject.message ||= 'Server Error'
3337

3438
delete defaultRes.headers['content-type'] // this would be set to application/json

0 commit comments

Comments
 (0)
0