I have an app running with React, Redux and Next.js. In my redux store I have a user which has, let's say, an attribute "type". Each type of users has its own array of "routes" it can access.
What is the best way to prevent the user from accessing certain routes ? I am able to redirect with Next.js Middleware but I cannot manage to pass a variable to the request with the user's type.
Maybe you can use the type as a parameter at the end of the URL. (See https://www.semrush.com/blog/url-parameters/). These parameters can be accessed in NextJS functions like getInitialProps and getServerSideProps, and also in the client-side using next/router.
Using such parameters, you can handle redirects and/or data-fetches according to the type.