The bug is the Homepage / is broken when you combine the following:
- App Router
- Trailing slash
- i18n config
- Middleware
We have this configuration (and more) because in our production app :
- we have a domain per locale,
- we need trailing slash because of legacy,
- we need the middleware to get the locale in App Router because it does not work by default, also dealing with redirections, etc.
Actualy we have Pages Router + App Router because we did not have time to migrate all pages to App Router.
📝 Add dev domains in your /etc/hosts file:
127.0.0.1 www.dev.fr www.dev.es www.dev.it www.dev.de www.dev.ch www.dev.nl
- Go to: http://www.dev.fr
- See broken homepage (white screen) with logs:
inject.bundle.js:1 Uncaught Error: Automatic publicPath is not supported in this browser at inject.bundle.js:1:12813 at inject.bundle.js:1:12976 at inject.bundle.js:1:271814 (anonymous) @ inject.bundle.js:1 (anonymous) @ inject.bundle.js:1 (anonymous) @ inject.bundle.js:1
You can test the following cases:
(revert any changes)
- Rename
./src/midleware.tsinto./src/__middleware.tsfor instance - Refresh http://www.dev.fr : the Home page is working.
- Go to http://www.dev.fr/test/ : the Test page is working also.
(revert any changes)
- Comment the
trailinSlash: trueline innext.config.ts. - Refresh http://www.dev.fr : the Home page is working.
- Go to http://www.dev.fr/test/ : the Test page is working also.
(revert any changes)
- Comment the
i18nconfig innext.config.ts. - Refresh http://www.dev.fr : the Home page is working.
- Go to http://www.dev.fr/test/ : the Test page is working also.