question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rewrites with i18n causes TypeError: Expected "nextInternalLocale" to be a string

See original GitHub issue

Bug report

Describe the bug

Using rewrites in next.config.js together with following i18n settings:

i18n: {
  locales: ['en', 'de'],
  defaultLocale: 'de',
  localeDetection: false,
}

Rewrite example:

async rewrites() {
    const rewrites = [
      {
        source: '/gssp-alternative',
        destination: '/gssp',
      },
    ];

    return rewrites;
  },

Navigating in browser from / to /gssp-alternative causes a client-side runtime error.

To Reproduce

https://repl.it/@berndartmueller/nextjs1003-nextInternalLocale-bug

  1. Click on “CLICK HERE TO SEE ERROR” link
  2. Error popup is shown with error TypeError: Expected "nextInternalLocale" to be a string

Expected behavior

No error.

System information

  • OS: macOS
  • Browser: does not matter
  • Version of Next.js: 10.0.3
  • Version of Node.js: Don’t know, it’s repl.it 😄
  • Deployment: next dev

Thanks a lot!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kivohincommented, Nov 30, 2020

I encounter the exact same error when using i18n Routing + Rewrites.

I already created a bug report (#19227) for another issue when I am using i18n Routing + Rewrites + Vercel Now.

But the attached demo repository (https://github.com/kivohin/i18n-routing-rewrites-vercel-now) in that bug report can be used to reproduce the mentioned error (TypeError: Expected "nextInternalLocale" to be a string).

I still get it even when using the suggested locale: false option on Next.js v10.0.3.

@berndartmueller, @MSefer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rewrites - next.config.js
rewrites is an async function that expects to return either an array or an object of arrays (see below) holding objects with source...
Read more >
Problem finding string atached to json file when translating ...
When you are translating with i18n, and get this error, it could be because you have altered the translation JSON file and the...
Read more >
i18n - npm
Lightweight simple translation module with dynamic JSON storage. Supports plain vanilla Node.js apps and should work with any framework (like ...
Read more >
How to Localize a Svelte App with svelte-i18n | Phrase
Of course, if you use Svelte, you already know that it's a compiler, not a framework that ships with your production code. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found