QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.25k stars 59 forks source link

[next-international] Locale "serviceworker.js" not found in locales (en, fr), returning "notFound()" #219

Closed myeljoud closed 11 months ago

myeljoud commented 11 months ago

Describe the bug next-international keeps logging out this error: ⨯ node_modules/.pnpm/next-international@1.0.1/node_modules/next-international/dist/app/server/index.js (175:61) @ eval ⨯ TypeError: locales[locale] is not a function at Generator.next (<anonymous>) at new Promise (<anonymous>) at NotFound (./app/[locale]/not-found.tsx:20:77) at stringify (<anonymous>) null

To Reproduce here is a stripped down version fo the application to test, btw I'm using pnpm. https://github.com/medyahyejoud/next_reprod.git

Expected behavior App shouldn't log out this message, I've done everything correctly.

Screenshots

Screenshot 2023-10-04 at 19 04 11

About (please complete the following information):

gustaveWPM commented 11 months ago

Ping @QuiiBz

Hey, it may be my fault. https://github.com/QuiiBz/next-international/issues/144

Ping @medyahyejoud

Maybe it is just a matcher issue in your middleware.ts file?

QuiiBz commented 11 months ago

Thanks for the reproduction. I cloned and run the app, but I don't get any error on the server nor client:

Screenshot 2023-10-05 at 10 34 41

Do you have any extension in your browser that could fetch this service worker.js file? You can try by going into private browsing.

As @gustaveWPM mentioned, you can also add serviceworker.js inside the matcher configuration of your middleware: https://github.com/medyahyejoud/next_reprod/blob/493d26bb1ffa4140f407f6a38ceda5004850308f/middleware.ts#L16

export const config = {
  matcher: ["/((?!api|static|.*\\..*|_next|favicon.ico|robots.txt|serviceworker.js).*)"],
};
myeljoud commented 11 months ago

Hey guys,

Hey @QuiiBz, thanks a bunch! I totally overlooked the isolated mode for opening the app. Just like you said, the issue got sorted out—it turned out to be the localhost cache and site data, possibly from other apps running on the same port. 🙌