I have a nextjs app using nextjs-auth0 and typescript. I'm a little confused about what I need to protect using auth0. I have read somewhere that components cannot be navigated to, only pages. I have also tried navigating to both server and client components as well as sending post requests to server components and I can't seem to do it. However, I have also read that server actions are like POST requests and should be treated like APIs.
Also, I'm using nextjs-auth0 v4 which doesn't have "withAuthenticationRequired", so I have to use getSession() and check for the user.
So, questions:
- Do I need to protect all server components that return any sesitive data?
2, a) If yes, is the best way to use getSession() on each component/method.
2, b) Or is it better to use middleware. In which case, if I use the matcher, should I then use redirects to prevent particular role groups from accessing certain functions?