-
-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serverSideTranslations crashes when called inside getServerSideProps on Vercel #1552
Comments
If you use module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'cs'],
localePath: path.resolve('./public/locales')
},
}; |
@CameronCT That's correct. |
Thank you very much, It helped. I still bumped into other similar issue with monorepo and i'm helpless. I created a separate issue. #1553 |
Thanks, it worked for me! |
I ran into the same issue. While this answer is correct #1552 (comment) I would add that you should not import the config on the client side in such case. Just pointing this out b/c there are some use cases where it's suggested to pass the config within If you'd do so you'll get One workaround could be the following (although I'm not sure that is such a good idea):
Example code: https://github.com/stophecom/next-i18n-vercel-issue Maybe it helps somebody :) |
For anyone wondering how to get this working in Netlify for dynamic routes, you need to make
My use case was a monorepo, and I did not need to make the Explained here: |
I tried @aleehedl's solution but it did not fix the issue I was having when deploying to netlify. It took me two full work days to find this solution which fixes both building locale pages and automatic locale redirects. So I thought I'd leave this comment here for people having the problem in the future. Hope it helps! ❤️ |
For anyone else who comes to this, @aleehedl 's solution worked for me, except since we are using a monorepo setup, (similar to https://github.com/belgattitude/nextjs-monorepo-example), instead of directly using the paths, we had to prefix them; something like below results in our toml file:
|
It works when I do "npm run build" and "npm start", but doesn't work on Vercel. Trying to solve it.... See: https://stackoverflow.com/questions/69656025/next-i18next-is-not-working-with-serversideprops-in-dynamic-pages-after-deployin and i18next/next-i18next#1552 and https://raw.githubusercontent.com/jakubHynek/vercel-next-18next/main/next-i18next.config.js and https://stackoverflow.com/questions/73199378/getting-next-config-warning-adding-nex-i18n-additional-property and https://github.com/i18next/next-i18next#6-advanced-configuration
None of this worked for me. |
An update for anyone with the same problem (specifically for Vercel): The solution by @CameronCT works, but I think it's outdated. The JSON structure should be as following: module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
localePath: path.resolve('./public/locales')
}; Basically, the |
I can confirm that this is also mandatory for AWS Amplify to obtain the translations. |
Translations are not shown properly in vercel, fix: i18next/next-i18next#1552 (comment)
@isaachinman @leoselig Hi guys, I am trying to deploy Next 13 to vercel and facing `const path = require('path'); export const nextI18NextConfig = { export type Locale = (typeof i18n)["locales"][number];` It works completly fine in local but and I dont need the localePath key but as I have researched, it needs that key for vercel deployments This is what i followed https://github.com/vercel/next.js/tree/canary/examples/app-dir-i18n-routing |
Describe the bug
When deployed to Vercel the
serverSideTranslations
function crashes when called insidegetServerSideProps
. When called ingetStaticProps
it works as expected. Locally everything runs fine.The deployed Vercel serverless function in which it runs gives me error:
Occurs in next-i18next version
^9.2.0
Steps to reproduce
Reproduction repository:
https://github.com/jakubHynek/vercel-next-18next
Running example
https://translations-wo-monorepo-kubhynek.vercel.app/
I initialized app using
yarn create next-app --typescript
and added simple translation usingnext-i18next
./
) -- withserverSideTranslations
called insidegetStaticProps
, there is a button that takes you to/ssr
page/ssr
) -- withserverSideTranslations
called insidegetServerSideProps
-- this page crashesSteps
The text was updated successfully, but these errors were encountered: