Skip to content

Non-english urls not working #10656

Answered by ziimakc
ziimakc asked this question in Help
Feb 24, 2020 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

You can solve this adding to next.config.js:

const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
})

const pathsToRewrite = [
  ['/пользователь/:id/:slug*', '/user/:id/:slug*'],
  ['/книга/:id/:slug*', '/book/:id/:slug*'],
  ['/тема', '/theme'],
  ['/ошибка', '/error_page'],
]
const rewrites = pathsToRewrite.map(([ru, eng]) => ({ source: encodeURI(ru), destination: eng }))
rewrites.push(...pathsToRewrite.map(([ru, eng]) => ({ source: ru, destination: eng })))

module.exports = withBundleAnalyzer({
  async rewrites() {
    return rewrites
  },
})

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jzaburunov
Comment options

@ziimakc
Comment options

Answer selected by ziimakc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants