-
Hi All ! I'm having a weird issue today that might be caused by next-intl. When I run my application both in the dev and prod build, I see this error in my console: The weird thing is that this error shows up only in my laptop and it's like an infinite loop! I have a team with 4 people, all of us tested to run the application and nothing is thrown and Vercel deployment is working actually. What I tried to solve it?
What might cause this error and how can I solve it ? |
Beta Was this translation helpful? Give feedback.
Replies: 23 comments 51 replies
-
@amannn Pinging to bring up attention because I encountered the same issue. What I discovered was that, there is actually some production request The issue is that if I make the matcher Not sure if this got any solution for now unfortunately, I am out of ideas of changing the matcher so that these apple icons will be excluded. |
Beta Was this translation helpful? Give feedback.
-
I'm getting the same error here. |
Beta Was this translation helpful? Give feedback.
-
The working example provided uses NextIntlClientProvider. We are not using that and instead, we follow the one here: I think this version is the one causing us problems. |
Beta Was this translation helpful? Give feedback.
-
I forgot what template I was using but using old/unupdated example is the
issue.
…On Thu, Sep 7, 2023, 5:42 PM Karren Rebosura ***@***.***> wrote:
The working example provided uses NextIntlClientProvider.
We are not using that and instead, we follow the one here:
https://github.com/amannn/next-intl/blob/feat/next-13-rsc/
I think this version is the one causing us problems.
—
Reply to this email directly, view it on GitHub
<#446 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEMW3XZLZ4PMTSZIL33F4VDXZJSX5ANCNFSM6AAAAAA3IRSYVE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Could it be the cause of this bug is this vercel/next.js#49442 |
Beta Was this translation helpful? Give feedback.
-
I'm on 3.0.0-beta.17 and |
Beta Was this translation helpful? Give feedback.
-
You have to set up |
Beta Was this translation helpful? Give feedback.
-
i need to set up this x-next-intl-locale with nginx? |
Beta Was this translation helpful? Give feedback.
-
I have the same error, i don't understand what should I do. should it work without any workaround in beta 17? or am I missing something? This is the log of my middleware
I also tried this:
same stuff as someone was suggesting but same story |
Beta Was this translation helpful? Give feedback.
-
i drop this module (temporary) from my project and it starts to work 2x faster. I think module have big problem with performance if you have some audience in project |
Beta Was this translation helpful? Give feedback.
-
I have managed to find out where these errors come from and why they only appear in production! It is because of the 404 page. The pages not having 404 specifically created, it loads the one that has next by default, and that... makes the function jump. It comes out in production because we constantly have crawlers that try to access wp-admins... |
Beta Was this translation helpful? Give feedback.
-
I managed to fix the error in my console since we do not have a better solution yet and it was getting me cary to see all thoes errors. This is my import { ReactNode } from 'react';
import { notFound } from 'next/navigation';
import { headers } from 'next/headers';
import { useLocale, useMessages } from 'next-intl';
interface LocaleLayoutProps {
children: ReactNode;
params: {
locale: string;
};
}
export default function LocaleLayout({ children, params }: LocaleLayoutProps) {
const header = headers();
const localeHeader = header.get('x-next-intl-locale');
if (localeHeader === null) {
notFound();
}
const locale = useLocale();
const messages = useMessages();
// Validate that the incoming `locale` parameter is a valid locale
if (params.locale !== locale) {
notFound();
}
// ... rest of the code
} Translations just works the same, but on the same request header without For debug purpose here is my headers list for a "healthy" request and an "unhealthy" request:
I tried to disable my extensions, nothing changed. |
Beta Was this translation helpful? Give feedback.
-
There's a new troubleshooting section in the docs in regard to this error: https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. It will also be linked to from the "Unable to find next-intl locale" message in the next beta release. |
Beta Was this translation helpful? Give feedback.
-
As far as I know, this cause when you have a dot sign "." in your url string, the request will not go to middleware where we set next-intl locale. I was facing the same error, then I just manually change "." to "DOT" which is quite more friendly for a url string. |
Beta Was this translation helpful? Give feedback.
-
If anyone is still having this issue check if you've put the middleware file in the right place. As stated in the Next.js docs.
|
Beta Was this translation helpful? Give feedback.
-
I was figuring this out for 3 hours.. my problem was that in middleware.js I had:
and I had to change it to:
My problem was that I wanted to create 404 error file to customize it by myself.. So only "." - dot I needed to remove to actually catch it right. This was only my case. |
Beta Was this translation helpful? Give feedback.
-
Got this error by using |
Beta Was this translation helpful? Give feedback.
-
For me the issue was that I had |
Beta Was this translation helpful? Give feedback.
-
F* this error, it made me all days to fix just for translation :) Now I uninstall package |
Beta Was this translation helpful? Give feedback.
-
There was an update to this in #742: |
Beta Was this translation helpful? Give feedback.
-
For me the problem was that I was using |
Beta Was this translation helpful? Give feedback.
-
For us the problem was: it was working on my computer but not on my colleague's. And we figured out that .env.local file is not there 🤦♂️ which was keeping supabase keys. |
Beta Was this translation helpful? Give feedback.
-
Here is my
|
Beta Was this translation helpful? Give feedback.
Update Dec 12, 2023: If you're still encountering this error, there's a troubleshooting section in the docs now.
I've worked on a PR that could address this, please see the supplemental info here: #506
Since this doesn't seem to have any downsides, I've released it as
next-intl@3.0.0-beta.17
. Can you have a look to see if it solves the issue you're seeing?