From c7d7992778d1224480bb7988f3cd65da632c5c8b Mon Sep 17 00:00:00 2001 From: Saeid Zareie Date: Thu, 16 Jan 2025 12:10:10 +0330 Subject: [PATCH] fix: get url from event.path --- packages/nuxt/src/core/runtime/nitro/error.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/src/core/runtime/nitro/error.ts b/packages/nuxt/src/core/runtime/nitro/error.ts index a472c56a31..ecc4265feb 100644 --- a/packages/nuxt/src/core/runtime/nitro/error.ts +++ b/packages/nuxt/src/core/runtime/nitro/error.ts @@ -4,7 +4,6 @@ import type { H3Event } from 'h3' import { getRequestHeader, getRequestHeaders, - getRequestURL, getResponseHeader, send, setResponseHeader, @@ -23,7 +22,6 @@ export default defineNitroErrorHandler( async function defaultNitroErrorHandler (error, event) { const { stack, message, isSensitive, statusCode, statusMessage } = normalizeError(error) - const url = getRequestURL(event, { xForwardedHost: true, xForwardedProto: true }).toString() // https://github.com/poppinss/youch let youch: Youch | null = null @@ -35,7 +33,7 @@ export default defineNitroErrorHandler( // Create an error object const errorObject = { - url, + url: event.path, statusCode, statusMessage, message, @@ -66,6 +64,7 @@ export default defineNitroErrorHandler( const ansiError = ( await youch!.toANSI(error) ).replaceAll(process.cwd(), '.') + if (!columns) { process.stderr.columns = columns } @@ -75,7 +74,7 @@ export default defineNitroErrorHandler( errorToLog = error.message || error.toString() || 'internal server error' } - console.error(`${tags} [${event.method}] ${url}\n\n`, errorToLog) + console.error(`${tags} [${event.method}] ${event.path}\n\n`, errorToLog) } if (event.handled) { return } @@ -93,7 +92,7 @@ export default defineNitroErrorHandler( event, await youch!.toHTML(error, { request: { - url, + url: event.path, method: event.method, headers: getRequestHeaders(event), },