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

Chunk Load Error using dynamic routes ([lang]) #62479

Open
leof240 opened this issue Feb 24, 2024 · 5 comments
Open

Chunk Load Error using dynamic routes ([lang]) #62479

leof240 opened this issue Feb 24, 2024 · 5 comments
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@leof240
Copy link

leof240 commented Feb 24, 2024

Link to the code that reproduces this issue

https://github.com/leof240/chunk_load_error_nextauth-nextintl

To Reproduce

  1. build the project
  2. deploy on prod server
  3. go to a dynamic locale page like http:site/en
  4. the page is showing an error on chunk load error

Current vs. Expected behavior

Current:
In development the site is working as expected.
in a production build and production environment, the site is throwing a Chunk Load Error on the page js file behind
Screenshot 2024-02-24 at 12 47 07
the buttons on the page do not work

Expected:
The expected behaviour is to show a page with 2 buttons for signin and sign out. when clicking the signin button, the session is updated and after a page refresh is shown from the layout and the page.
it's also showing the page title translated into different languages for the /en, /fr, / it

Provide environment information

Node 20.1

npm v9.8.1

Which area(s) are affected? (Select all that apply)

Not sure, App Router, Internationalization (i18n), Middleware / Edge (API routes, runtime)

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed), Other (Deployed)

Additional context

the "next" package is updated to canary version ( 24 / 02 / 2024)

cannot reproduce the error on development environment with npm run start

@leof240 leof240 added the bug Issue was opened via the bug report template. label Feb 24, 2024
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Feb 24, 2024
@leof240
Copy link
Author

leof240 commented Feb 24, 2024

I managed to remove the next-intl library and the error still persists.

it seems it's occurring when a server component has client components within a dynamic route, so not really dependednt on any external libraries.

@Mifaresss
Copy link

I had a similar problem. You should add env NEXTAUTH_URL=your_domain
And maybe use .env.local

@leof240
Copy link
Author

leof240 commented Feb 24, 2024

I had a similar problem. You should add env NEXTAUTH_URL=your_domain And maybe use .env.local

I'm doing that locally for another project, but it doesn't make any difference

@leof240
Copy link
Author

leof240 commented Feb 25, 2024

I was able to fix the error. It's related to the previous errors on dynamic routs. There was a problem in the encoding url in server.js

The url was all lower case having the encoded square brackets lowercase therefore not properly encoded. (%5b instead of %5B)

I added a replace statement before the url processing. I'll post the code later for awareness

@leof240 leof240 changed the title Chunk Load Error with next-auth and next-intl using dynamic routs ([lang]) Chunk Load Error using dynamic routes ([lang]) Feb 26, 2024
@akhrarovsaid
Copy link

@leof240 Hey Leof 👋

Any chance you got that code handy? I'm currently experiencing an almost identical issue except my uri is getting encoded twice around my slug. So, I'm getting %255B instead of %5B... incredibly frustrating.

Using Next v13.5.6.

Appreciate any help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants