I am using the next-intl package to implement internationalisation in NextJS 14 application. I did the setup with-i18n-routing. And now I am getting the following error in the server logs, almost on every request nextwork-
Unable to find next-intl
locale because the middleware didn’t run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The notFound()
function will be called as a result.
Can anyone help me with how can I fix this so that this error will not show up in the log again.
I am using following version of the library.
“next”: “14.1.0”,
“next-intl”: “3.14.0”,
I checked the link provided in the error and went through all the scenario’s mentioned over there – link[ https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale ]. I am sure that I have not made any of the mistakes metioned. I also tried implemeting middleware in the exact way as given in the example in the github repo – link [ https://github.com/amannn/next-intl/tree/main/examples/example-app-router ]. I also checked the library source code to see from where the error message is coming from and it can be seen that it is checking for ‘X-NEXT-INTL-LOCALE’ header in the request inside getLocaleFromHeaderImpl function and if it do not found it then it prints this error. And incoming request do not have this header and might be because of that this is happening.
I am expecting a proper solution to this problem from anyone who can help me with it. Thank you!
RUSHIKESH CHAUDHARI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.