Skip to content

Commit

Permalink
fix: server.js bug
Browse files Browse the repository at this point in the history
  • Loading branch information
521xueweihan committed Aug 10, 2024
1 parent bfb492a commit 8a8c88e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { i18n } = require('./next-i18next.config');

module.exports = withBundleAnalyzer({
i18n,
trailingSlash: false,
reactStrictMode: false,
compress: true, // 启用压缩
eslint: {
Expand Down
13 changes: 6 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ async function startServer() {

req.locale = locale;

// 处理尾部斜杠并重定向
if (req.url.length > 1 && req.url.endsWith('/')) {
const newUrl =
req.url.slice(0, -1) +
(req.url.includes('?') ? req.url.slice(req.url.indexOf('?')) : '');
return res.redirect(301, newUrl);
}
// // 处理尾部斜杠并重定向
// if (req.url.length > 1 && req.path.endsWith('/')) {
// const newUrl =
// req.path.slice(0, -1) + req.params
// return res.redirect(301, newUrl);
// }

next();
}
Expand Down

0 comments on commit 8a8c88e

Please sign in to comment.