Is there a way to authenticate all nested routes in my project? Some routes require authentication, while others can be accessed without it. For example:
/admin => requires authentication
/admin/posts => requires authentication
/admin/posts/1 => requires authentication
/admin/users => requires authentication
and so on...
/view => can be accessed without authentication
/view/songs => can be accessed without authentication
/view/posts => can be accessed without authentication
Things I have tried:
HOC: need to include it in every route inside admin. Is there a way to do it in a common place?
getServerSideProps: same as above
Is there a way to achieve this in one common file?