Skip to content

Commit

Permalink
fix(server): handle decodeURI error (#5243)
Browse files Browse the repository at this point in the history
  • Loading branch information
phof authored and pi0 committed Mar 16, 2019
1 parent 37cd24c commit 5b7f6d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/server/src/middleware/nuxt.js
Expand Up @@ -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 {
Expand Down Expand Up @@ -82,6 +82,9 @@ export default ({ options, nuxt, renderRoute, resources }) => async function nux
return err
}

if (err.name === 'URIError') {
err.statusCode = 400
}
next(err)
}
}
Expand Down

0 comments on commit 5b7f6d7

Please sign in to comment.