mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +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) {
|
||||
// Get context
|
||||
const context = getContext(req, res)
|
||||
const url = decodeURI(req.url)
|
||||
|
||||
res.statusCode = 200
|
||||
try {
|
||||
const url = decodeURI(req.url)
|
||||
res.statusCode = 200
|
||||
const result = await renderRoute(url, context)
|
||||
await nuxt.callHook('render:route', url, result, context)
|
||||
const {
|
||||
@ -82,6 +82,9 @@ export default ({ options, nuxt, renderRoute, resources }) => async function nux
|
||||
return err
|
||||
}
|
||||
|
||||
if (err.name === 'URIError') {
|
||||
err.statusCode = 400
|
||||
}
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user