-
Notifications
You must be signed in to change notification settings - Fork 86
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
Can't access locale files in public directory from nested routes using getServerSideProps #359
Comments
hey @hrahimi270 ! good news, we just recently released support for this :). check out this section of the README: https://github.com/netlify/netlify-plugin-nextjs#local-files-in-runtime. throwing "public" in included_files should solve your problem! if that works for you, we could possibly update this issue to a feature request asking for public to be included by default? let me know! |
Hey @lindsaylevine. Thanks for the response. |
@hrahimi270 hmm, can you try path.resolve(process.cwd(), '/public/locales')? or maybe not using path.resolve? i can't remember at the moment what the correct usage. this uses process.cwd() and i know we had a next-i18next issue that worked with included_files as public/*. if that doesn't work, if you wanted to give me a repo to try to figure out, i could maybe better help that way! |
Then I will test |
Hey @lindsaylevine. Also, deployed it on Netlify to see the error when clicking on brands. Thanks for your time. |
Hi @hrahimi270! Thanks for the detailed report and the reproduction repo — these were super helpful. Can you try to add to your build an environment variable named This will enable a functionality that we're planning to roll out next week, and from my tests it should fix your issue. Let me know how you get on. Thanks! |
Hi @eduardoboucas. Yes, it works fine now with that variable 🤘🏼 |
I'm glad it works! 🎉 And yes, please use that variable until this change is rolled out. I'll update this issue once that happens. Thanks! |
This has now been rolled out. @hrahimi270 can you please check if it works without the environment variable? Thanks! |
@eduardoboucas |
Describe the bug
I'm using the built-in feature of internationalization of Nextjs. I don't want to use other third-party modules for translations of my app.
So I decided to put my translations in
/public/locales
and access them usinggetServerSideProps
for dynamic pages andgetStaticProps
for static pages.Static pages work fine. But dynamic pages not working and they are not able to access the file using
getServerSideProps
.This is the error I have on netlify:
Also, I'm trying to get my translations simply by this lines of codes in both pages:
Expected behavior
Have my translations in both Static and Dynamic pages.
Versions
The text was updated successfully, but these errors were encountered: