mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
fix(server): handle decodeURI error (#5243)
This commit is contained in:
parent
37cd24c261
commit
5b7f6d78ec
@ -7,10 +7,10 @@ import { getContext } from '@nuxt/utils'
|
|||||||
export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware(req, res, next) {
|
export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware(req, res, next) {
|
||||||
// Get context
|
// Get context
|
||||||
const context = getContext(req, res)
|
const context = getContext(req, res)
|
||||||
const url = decodeURI(req.url)
|
|
||||||
|
|
||||||
res.statusCode = 200
|
|
||||||
try {
|
try {
|
||||||
|
const url = decodeURI(req.url)
|
||||||
|
res.statusCode = 200
|
||||||
const result = await renderRoute(url, context)
|
const result = await renderRoute(url, context)
|
||||||
await nuxt.callHook('render:route', url, result, context)
|
await nuxt.callHook('render:route', url, result, context)
|
||||||
const {
|
const {
|
||||||
@ -82,6 +82,9 @@ export default ({ options, nuxt, renderRoute, resources }) => async function nux
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err.name === 'URIError') {
|
||||||
|
err.statusCode = 400
|
||||||
|
}
|
||||||
next(err)
|
next(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user