Middleware or server.js modification to load specific file from pages folder
Unanswered
Oriental Scops-Owl posted this in #help-forum
Oriental Scops-OwlOP
Next.js 11, is there a way i can intercept a request with middleware or modifying the server.js so that if a user has a loggedIn state, it would load a specific file from the pages folder?
for example, if user is logged in, load the pages/someComponent.js file, if not load pages/someOtherComponent.js .
one of the 2 files would be using getStaticProps and another would be using getServersideProps
I want to have a dynamic page for users who are logged in, and a cached page for non logged in users (for Google crawling etc)
i need it to work on dev and prod builds
for example, if user is logged in, load the pages/someComponent.js file, if not load pages/someOtherComponent.js .
one of the 2 files would be using getStaticProps and another would be using getServersideProps
I want to have a dynamic page for users who are logged in, and a cached page for non logged in users (for Google crawling etc)
i need it to work on dev and prod builds