mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
fix(nuxt): use app.baseURL
when fetching error page on server (#8888)
Co-authored-by: Toby Faux <tobyfaux@Tobys-MacBook-Pro.local>
This commit is contained in:
parent
52c2bffa76
commit
3e34a61506
@ -1,7 +1,7 @@
|
|||||||
import { withQuery } from 'ufo'
|
import { joinURL, withQuery } from 'ufo'
|
||||||
import type { NitroErrorHandler } from 'nitropack'
|
import type { NitroErrorHandler } from 'nitropack'
|
||||||
import { H3Error, setResponseHeader, getRequestHeaders } from 'h3'
|
import { H3Error, setResponseHeader, getRequestHeaders } from 'h3'
|
||||||
import { useNitroApp } from '#internal/nitro'
|
import { useNitroApp, useRuntimeConfig } from '#internal/nitro'
|
||||||
import { normalizeError, isJsonRequest } from '#internal/nitro/utils'
|
import { normalizeError, isJsonRequest } from '#internal/nitro/utils'
|
||||||
|
|
||||||
export default <NitroErrorHandler> async function errorhandler (error: H3Error, event) {
|
export default <NitroErrorHandler> async function errorhandler (error: H3Error, event) {
|
||||||
@ -47,7 +47,7 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
|||||||
// HTML response (via SSR)
|
// HTML response (via SSR)
|
||||||
const isErrorPage = event.req.url?.startsWith('/__nuxt_error')
|
const isErrorPage = event.req.url?.startsWith('/__nuxt_error')
|
||||||
const res = !isErrorPage
|
const res = !isErrorPage
|
||||||
? await useNitroApp().localFetch(withQuery('/__nuxt_error', errorObject), {
|
? await useNitroApp().localFetch(withQuery(joinURL(useRuntimeConfig().app.baseURL, '/__nuxt_error'), errorObject), {
|
||||||
headers: getRequestHeaders(event) as Record<string, string>,
|
headers: getRequestHeaders(event) as Record<string, string>,
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
}).catch(() => null)
|
}).catch(() => null)
|
||||||
|
Loading…
Reference in New Issue
Block a user