// nuxt.config.js export default { serverMiddleware: [ (req, res, next) => { try { decodeURIComponent(req.url); next(); } catch (err) { if (err instanceof URIError) { req.url = '/'; // 修改req.url成一个有用的URL res.writeHead(302, { Location: '/' }); res.end(); } else { next(err); } } }, ], // ...其他配置 };