Next.js build version fails with 'Cannot read property 'auth' of undefined'

For the past few months we’ve been working on a website based on Next.js with great joy. It all worked splendidly and had no big problems. However as of yesterday we’re suddenly getting an error on the production version when applying a router.push: Cannot read property 'url' of undefined. The router.push in question is as follows:

   pathname: `/catalogus/category=${filters.category[soortSelected].slug}`,
{ scroll: false }

The function where it goes wrong is called formatUrl, but I have no real clue as to it’s purpose (apart from the obvious function name of course). It get’s a urlObj as parameter, but where that comes from, I have no clue either.
The strange thing is, even reversing to an old commit does not seem to help, which is just baffeling to me.

Apparently it has something to do with the locale, as it only breaks on the ‘defaultLocale’ version and not any other language.

73 thoughts on “Next.js build version fails with 'Cannot read property 'auth' of undefined'”

Leave a Comment