How to protect all routes other than sign-in
Hi there, I am making an app where I only want signed-in users to see the content, I want all routes to automatically redirect to the sign-up page if the user is not signed in.
Ideally, I don't want to have to add the boilerplate to check if the user is signed up on every single page, I also don't want to have to create and maintain a massive list of all the protected routes (which is virtually every route in my app) when using middleware.
What is an easy way of setting something like this up?
Here is what I came up with, conditionally showing the route if the user has a session, though tbh it is a bit janky.
It sort of works, though when you sign out, you have to refresh to show the signup
Ideally, I don't want to have to add the boilerplate to check if the user is signed up on every single page, I also don't want to have to create and maintain a massive list of all the protected routes (which is virtually every route in my app) when using middleware.
What is an easy way of setting something like this up?
Here is what I came up with, conditionally showing the route if the user has a session, though tbh it is a bit janky.
It sort of works, though when you sign out, you have to refresh to show the signup