-
-
Notifications
You must be signed in to change notification settings - Fork 463
Next.js 10 localization in pathname #721
Comments
Yeah, Next.js 10 just came out two days ago, so it'll take some time to add those new features, since we have custom routing/rendering logic optimized for Lambda@Edge. I've tagged this with enhancement. But I've tested the existing end-to-end tests with Next.js 10 and nothing broke, so looks like all the existing features work as expected. |
Hi! I was wondering if there are any updates on this? |
Yes, I have not had a chance to look at it yet, been mostly on vacation mode the past few weeks so haven't worked on the code recently. Hoping to get to it once I'm back next week :) |
Thanks for the update! :) If it helps, when I tried deploying my site with the i18n solution it worked well on all locales, except for the default one, which returned 404 for all routes unless I manually added the locale prefix to the URL path. Hope you enjoy the rest of your holiday! :) |
Hi, I was wondering if there was any updates on this issue? |
I am planning to continue on this during this week. Apologies since lately I was the only contributor for this, so haven't had enough time to both triage issues and work on the codebase.. From initial looks, Next.js will generate new pages for each locale specified (for SSG). So then we would need to just create new routes in our manifests to direct the locale-prefixed paths to the right SSG pages. And without a local-prefix, it should use specified |
related to #830 |
Have published I haven't extensively tested it nor added complete tests for it yet, so please treat it as a preview for now and report any issues by opening a bug report. Thanks! Note: domain-based routing will be a separate issue |
Thanks for the update, everything is working as expected for us, except for the index.js page when using getStaticProps. For all locales, the base path returns an AccessDenied error due to index.html not being exported properly to the static-pages folder in S3. All other static routes are being exported properly. Using the trailingSlash config does not solve this issue, and changing getStaticProps to getServerSideProps renders the index path as expected. Let me know if you need more information! |
@testreen thanks! Let me take a look and fix that today. I might have missed testing |
Hey, many thanks for your update! I've bumped my app to the latest serverless version, and I seem to experience these issues:
Any ideas what could be causing this? How to possibly reproduce this:
this is my serverless config:
|
Yea, I will rework some of the changes today. Basically with locales then data files and pages would be put into locale-prefixed paths e.g As fix we need to copy Also if using locales, we can just have locale directories e.g |
@dphang all's good for me in production , but all i18n sub routes with SSG are not uploaded to S3 with local path like probably a problem with |
Thanks @benjipott for reporting, for that issue #646 I didn't have luck making progress on it. But will look at the other issue. |
@johnaxe not sure, I did not change anything client-side, so perhaps it might be Next.js converting the link component to wrong href? Is that the same behavior on the local dev server? |
I have noticed one use case that SSG with nextjs i18n only working from the root page (index.jsx). I put the same code on all pages for testing.
Here is my pocOptim:
component: '@sls-next/[email protected]'
inputs:
memory: 512
useServerlessTraceTarget: true This is my i18n: {
localeDetection: false,
locales: ['en', 'de'],
defaultLocale: 'en'
}, |
@krish-dev thanks, I will take a look, not sure if it's due to serverless trace target (I have only tested without it) |
You are correct @dphang, I did some testing without
|
@dphang - You are absolutely correct. I re-ran the deploy with alpha.42 version (which is now out) - and that problem has been resolved. My code deploys, and thus far the i18n issues I had been experiencing have been resolved. Thanks! |
@poppein @dphang I'm currently experiencing the Can either of you share a solution which might help address this? I tried adding a Any suggestions? |
@rhoiyds I unfortunately revert back to using plain react i18next and not next-18next as i couldn't get it to bundle properly |
@rhoiyds I ve managed to make it work by copying my |
Great to hear that @gouroujo! Did you manually copied this or do you have some task that you could share? |
@gouroujo Thanks for sharing your solution! I had really high hopes for it, however, unfortunately still no dice. The same error as always. If there's anything else you can share that might help, it would be greatly appreciated. |
Hi all, after days of headaches I've managed to find a workaround which seems to work for me. Removed
Changed the next-i18next.config file from a .js to a .ts
In tsconfig.json (root of the project) I included the newly created
In
And did so similarly with any page that needs
What an absolute pain that was. I hope this helps anyone out there with the same issue. Also hope this gets resolved and that serverless next.js can properly locate the module without needing to duplicate the configs. Just some musings: It seems when you run Can provide more details of my projects configs if necessary. Good luck all. |
Thanks all for the help, let me look into it next. Unfortunately I am not using next-i18next myself yet and don't have enough time to look at various integrations (being the primary contributor to this) so I will take a look and try to repro & fix for the next minor version |
@rhoiyds' approach worked. You can see the same conclusion here: i18next/next-i18next#990 (comment) |
Guys, is the automatic locale selection working for you guys in AWS/LambdaEdge? |
Are you forwarding the Accept-Language header in CloudFront configuration? This is needed to detect the user's locale |
Yes, that seems to be the problem, I'm checking how to change the Cloudfront behavior (I thought it was done :) ) |
So I tried this, and things sadly didn't work as expected. I added Accept-Language to the nextjs serverless configuration. After I removed the Accept-Language Header in the serverless configuration, I still see it in Cloudfront (see screenshot) for the Path Pattern Update: I ended up putting headers: "none" for the time being. |
On my case it is working as expected, weird. Leaving the CDK code just in case it is useful for someone:
|
It was giving me this error too when using the latest version @sls-next/[email protected] - but I managed to fix it by downgrading to the latest stable version (@sls-next/[email protected]) and now it works fine. |
By the way, somebody found how to fallback to the most approximate locale? Example:
When I hit with |
@ignaciolarranaga I'm having the same problem. It works fine locally, but not after deploying to production. Update: it seems to be an issue with Next.js vercel/next.js#20488 |
Hey, just migrated to 1.9.0-alpha.4 and keeps in loop when not correctly recognize the locale. |
I think most of the major issues (locale redirection, precedence etc.) should be fixed now in the latest versions, so I'll close this and please open a new issue so it's easier to track specific issues. Thanks! |
Sorry to continue the discussion, but I reverted all of my previously mentioned changes, updated to the latest version of serverless component as well as nexti18next and tested a serverless deployment. It successfully deploys, however all I get is 404's on all of my routes. |
Can you post any more details of .serverless_nextjs directory / manifests and also if there is any reproduction you can share. Might be good to open a new issue so it's easier to isolate the problem? |
Hey, I was wondering if there were any updates on this issue? |
@sedagulkesen sorry, not sure specifically what update you were looking for? What issue are you facing? Since this one was closed and I did not get any other responses after the latest comments. I would say to better isolate any issues, please open a new issue with specific details. |
I am using Nextjs version 11.
With this configuration, all the routes are available. It is working on my locale perfectly. However, when I deploy it using serverless-next.js it gives 404 for all the routes by default. Unless I manually add the locale prefix to the URL path, it is not working. So initially Could you please help me out with this? update: it was about the Dockerfile, copying
|
Thanks @sedagulkesen for the update, glad to hear you managed to solve it. For reference if you have further problems, it would be good to try to repro the problem using our test app: https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/e2e-tests/next-app-with-locales (this is the one we run tests on, so if something is broken and you can repro here, it will make it easier to fix and add test coverage on). |
This threw me into a panic for several hours. I am very grateful for your sharing the solution as it resolved the issue for me as well. Specifically see this example - vercel/next.js#16995 (comment) |
Hey @dphang, was an issue related to domain-based routing created? I’m trying to use internationalized routing based on domain in the latest version and I could manage only on the default locale or when I explicitly set the locale in the path. I saw this issue but was not sure it is the one addressing the problem I described #1283 Thanks for the support |
Thank you for the fix, :) |
The new built-in localization in Next.js 10 allows to have the locale as a path prefix, e.g.:
All three routes will open
pages/about.tsx
. This works fine when I run it locally.When I deploy it using serverless-next.js, it gives a 404 for
/de/about
and/es/about
. Just/about
still works.Is this something that the Serverless Next.js Component doesn't support yet, or am I doing something wrong?
Thanks!
The text was updated successfully, but these errors were encountered: