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

fix(RSC): Always read header in RSC render #506

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

amannn
Copy link
Owner

@amannn amannn commented Sep 14, 2023

Should fix #446

As far as I understand the issue currently, something like this happens:

  1. The middleware receives a request where the NEXT_LOCALE cookie is set
  2. During the RSC render, the NEXT_LOCALE cookie is suddenly not available

If this is the case, this would fix the issue.

If however the middlware doesn't run at all for some reason, this will not make a difference. However, since this doesn't seem to have any downsides (possible since newer Next.js versions), this might simplify the code anyway and is a welcome change.

@vercel
Copy link

vercel bot commented Sep 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 7:23am
next-intl-example-next-13 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 7:23am

@amannn amannn marked this pull request as ready for review September 14, 2023 07:33
@amannn amannn merged commit 37c131b into feat/next-13-rsc Sep 14, 2023
6 checks passed
@amannn amannn deleted the fix/next-13-rsc-always-use-header branch September 14, 2023 07:36
@carlosmca44
Copy link

At this moment I get a new error that I don't know if it has to do with nextjs 13.5.4 or with next-intl. The thing is that in all the tutorials that I have seen and even documentation, everywhere in the rootlayout they use the useLocale() hook and no one has a problem, it does give me a problem since it is a hook and the hooks cannot be server side
The error shown is the following:

 ✓ Compiled in 761ms (1242 modules)
 ⨯ node_modules/next-intl/dist/esm/server/RequestLocale.js (1:580) @ eval
 ⨯ Error: Unable to find `next-intl` locale, have you configured the middleware?`
    at RootLayout (./src/app/[locale]/layout.tsx:29:73)
    at async Promise.all (index 0)
null

My configuration is to the letter with the documentation and on par with other programmers, but no one else gets the same error as me, or at least for the same reason.
I will be really thankful if you or anybody can help me with this problem.

@matee-safi
Copy link

I get the same error as well

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

Successfully merging this pull request may close these issues.

3 participants