1

next.config.js

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'ko', 'ar'],
  },
  async redirects() {
    return [{
      source: '/ko',
      destination: '/myCustomKo',
      permanent: true,
      locale: false,
     }]
  },
  async rewrites() {
    return {
      afterFiles: [{
        source: '/myCustomKo',
        destination: '/ko',
      }]
    }
  }
}

I want to use my /ko route to /myCustomKo.

It works only when it is loaded first. I can see /myCustomKo instead of /ko.

and I move route with <Link href="/">root</Link>, my subpath is gone. I expect it still be /myCustomKo not /.

when I try this process in /en, everything is perfect. I clicked <Link />, it still be /en.

How can I keep my custom subpath?

Summary

When my subpath is /en, I can route anywhere with /en.

When my subpath is /ar, I can also route anywhere with /ar.

But when my subpath is /myCustomKo, my router miss /myCustomKo subpath.

kyun
  • 9,710
  • 9
  • 31
  • 66

0 Answers0