Skip to content
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

getServerSideProps doesn't support serverSideTranslations #1141

Closed
MarvinZeising opened this issue Apr 12, 2021 · 4 comments
Closed

getServerSideProps doesn't support serverSideTranslations #1141

MarvinZeising opened this issue Apr 12, 2021 · 4 comments

Comments

@MarvinZeising
Copy link

Description

When using serverSideTranslations inside getServerSideProps, the page doesn't load.
It does work with a production build locally, but not if pushed to Vercel.

I know this has to be some kind of deployment issue, but maybe someone knows what I can do about it. I've looked into the next-i18next code trying to understand what's going wrong but I don't have enough NextJS knowledge.

Maybe there's a documentation page for this repo? Aside from the README, I couldn't find anything.

Occurs in next-i18next version

"i18next": "^20.2.1",
"next": "10.0.5",
"next-i18next": "^8.1.3",
"react": "^17.0.2",
"react-dom": "^17.0.2"

Steps to reproduce

I took the "simple" example from this repo and changed the getStaticProps on the second page to getServerSideProps. Added the missing packages to the package.json and deployed it to vercel (https://simple-2e6voz5th-marvinzeising.vercel.app).

image

Opening the second page now results in a 500 error page.

image

On the server, I can see this:

image

Is getServerSideProps not supported? I found an issue (#652) regarding that but I think that one is quite old.

Expected behaviour

For it to work just like in getStaticProps, I guess.

Screenshots

See above.

OS (please complete the following information)

  • Device: MBP 2018 15"
  • Browser: Microsoft Edge Version 89.0.774.54 (Official build) (64-bit)
@isaachinman
Copy link
Contributor

isaachinman commented Apr 12, 2021

You need to use:

localePath: path.resolve("./path/to/your/locales")

@JavierCaroelli
Copy link

How can you fix it ?

@MuhammadHasham23
Copy link

Any updates on this one?

@isaachinman
Copy link
Contributor

@JavierCaroelli @MuhammadHasham23 This issue had nothing to do with getServerSideProps. When deploying to Vercel, you must use path.resolve to force the Vercel serverless build to include your locales directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants