strapi / nextjs-corporate-starter

Strapi Demo application for Corporate Websites using Next.js
MIT License
955 stars 285 forks source link

Uncaught Error: invariant expected app router to be mounted #91

Closed jj6990 closed 8 months ago

jj6990 commented 8 months ago

Screen Shot 2023-10-17 at 08 30 54 Does anyone knows why is this issue happening? node 16.8.0

PaulBratslavsky commented 8 months ago

I will try to reproduce. But so far I haven't seen this error. But I am also on node 18. Not sure if it makes a difference though.

PrimeTimeTran commented 8 months ago

Ditto from me. I'm on node 18.18.0

Screenshot 2023-10-20 at 4 29 16 AM Screenshot 2023-10-20 at 4 29 11 AM

I got the error to go away by messing around with pageExtensions inside of next.config.js like this issue.

RS the server and the error goes away but the app 404s.

Screenshot 2023-10-20 at 2 37 45 PM

We can fix the 404:

But that breaks the template entirely and then app router & page router don't seem to work together.

New to NextJS so I'm just taking shots in the dark here and don't fully understand even after reading through the docs.

Appreciate your help so far and in advance!

PrimeTimeTran commented 8 months ago

I figured it out, need to actually set up the token, assumed it was placeholder and not required. Thanks for your work!

https://www.youtube.com/watch?v=a23JvssqrrQ&ab_channel=Strapi

PrimeTimeTran commented 8 months ago

Just a suggestion, an error message/prompt might be helpful for future users.

jj6990 commented 8 months ago

Thanks guys for your help this actually worked for me as well not sure why in production worked normally and locally it didn't

PaulBratslavsky commented 8 months ago

Thank you all amazing folks. @PrimeTimeTran if you have time, would you like to make a PR for it?

PrimeTimeTran commented 8 months ago

@PaulBratslavsky your wish is my command. lol =).

https://github.com/strapi/nextjs-corporate-starter/pull/96

PaulBratslavsky commented 8 months ago

@PrimeTimeTran you are awesome. Thank you and merged. https://github.com/strapi/nextjs-corporate-starter/pull/96

ankycheng commented 4 months ago

For me, to resolve this error I also have to set up metadata/ global properties in the admin if you are working on a brand new project. Otherwise, lacking of these data will cause rendering errors.