mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(bridge): respect --fail-on-error
in generation (#3134)
* fix(bridge): respect `--fail-on-error` in generation * fix: use `res.ok()`
This commit is contained in:
parent
a8c532be9a
commit
c02e3683eb
@ -1,7 +1,7 @@
|
|||||||
import { promises as fsp } from 'fs'
|
import { promises as fsp } from 'fs'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import { addPluginTemplate, useNuxt } from '@nuxt/kit'
|
import { addPluginTemplate, useNuxt } from '@nuxt/kit'
|
||||||
import { stringifyQuery } from 'ufo'
|
import { joinURL, stringifyQuery } from 'ufo'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware, scanMiddleware, writeTypes } from '@nuxt/nitro'
|
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware, scanMiddleware, writeTypes } from '@nuxt/nitro'
|
||||||
import { AsyncLoadingPlugin } from './async-loading'
|
import { AsyncLoadingPlugin } from './async-loading'
|
||||||
@ -216,9 +216,13 @@ function createNuxt2DevServer (nitroContext: NitroContext) {
|
|||||||
if (!listener) {
|
if (!listener) {
|
||||||
throw new Error('There is no server listener to call `server.renderRoute()`')
|
throw new Error('There is no server listener to call `server.renderRoute()`')
|
||||||
}
|
}
|
||||||
const html = await fetch(listener.url + route, {
|
const res = await fetch(joinURL(listener.url, route), {
|
||||||
headers: { 'nuxt-render-context': stringifyQuery(renderContext) }
|
headers: { 'nuxt-render-context': stringifyQuery(renderContext) }
|
||||||
}).then(r => r.text())
|
})
|
||||||
|
|
||||||
|
const html = await res.text()
|
||||||
|
|
||||||
|
if (!res.ok) { return { html, error: res.statusText } }
|
||||||
|
|
||||||
return { html }
|
return { html }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user