它在本地工作。然而,一旦我把它部署到firebase上,它就会导致nextServer 500内部错误。
next-i18next版本
8.1.3
配置
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'ko'],
},
};代码
_app.tsx
import { appWithTranslation } from 'next-i18next';
const App = ({ Component, pageProps }: AppProps): JSX.Element => {
return (
<Provider store={store}>
<MainWrapper>
<Component {...pageProps} />
</MainWrapper>
</Provider>
);
};
export default appWithTranslation(App);关于serverSideRendering的代码片段
export const getStaticProps: any = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, [])),
},
});export const getServerSideProps: GetServerSideProps = async (context) => {
const { teamId, email } = context.query;
let teamName;
if (!teamId) {
return { props: {} };
}
if (teamId) {
teamName = await getTeamName(teamId as string);
}
return {
props: {
teamId,
teamName,
email: email || '',
...(await serverSideTranslations(context.locale, [])),
},
};
};发布于 2021-09-09 11:19:07
我有同样的问题,然后我记得我必须在更改next.config.js文件后手动重启NEXTJS服务器。
重启服务器帮了我大忙。
发布于 2021-04-13 07:24:52
几天前我也遇到了同样的错误,在我的例子中,根本原因是我的next.config.js文件。我使用的是next-compose-plugins,无法使其与i18n的配置一起工作。
这就是我之前设置的方法:
// next.config.js
module.exports = withPlugins([
[
withImages({
esModule: true
})
],
i18n // error
])所以现在我要添加不带withPlugins的配置
// next.config.js
module.exports = withImages({
esModule: true,
i18n
})我不确定这是否适用于您,但出于调试目的,我建议您仅使用i18n配置测试您的应用程序。
// next.config.js
module.exports = {
i18n
}我的next-i18next.config.js示例
// next-i18next.config.js
module.exports = {
i18n: {
locales: ['pt', 'en-US'],
defaultLocale: 'pt'
}
}发布于 2021-05-25 01:07:25
当使用next-compose-plugins时,从他们的Usage section,
// next.config.js
const withPlugins = require('next-compose-plugins');
module.exports = withPlugins([...plugins], nextConfiguration);nextConfiguration应该是配置,意思是一个对象。
因此,下面的代码片段应该可以工作:
module.exports = withPlugins(
[withMdx(mdxConfig)],
{
i18n,
}
)https://stackoverflow.com/questions/67014108
复制相似问题