-
Hello everyone! 👋 I'm currently working on a personal NextJS SSG project, using 9.5 and React Context API for multilingual support. You can see the whole project here. My pages folder structure looks like:
The // export const getInitialLocale = () => {
// const [browserSetting] = navigator.language.split('-')
//
// if (LOCALES.includes(browserSetting)) {
// return browserSetting
// }
//
// return DEFAULT_LOCALE
// }
import Head from 'next/head'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { getInitialLocale } from '@utils/locale'
export default function Index() {
const router = useRouter()
useEffect(() => {
router.replace('/[lang]', `/${getInitialLocale()}`)
})
return (
<Head>
<meta key="robots" name="robots" content="noindex, nofollow" />
</Head>
)
} Everything works fine, and now I'd like to have no more
I simply tried to use newly released const isProd = process.env.NODE_ENV === 'production'
module.exports = {
assetPrefix: isProd ? '/' : '',
trailingSlash: true,
async rewrites() {
return [
{
source: '/fr/:path',
destination: '/:path'
}
]
}
} But in development mode, nothing happens... So I was wondering, if there was a limitation in the use of Thx in advance! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello again 👋 After reading more accurately NextJS documentation, it seems I missed an important point: |
Beta Was this translation helpful? Give feedback.
Hello again 👋 After reading more accurately NextJS documentation, it seems I missed an important point:
rewrites
asredirects
methods "are only available on the Node.js environment"... So I guess that it's the reason why it didn't work for me with static export^^