Replies: 3 comments 1 reply
-
I feel you. This is my major pain point with Remix. As far as I know, there's no good way until the loader/action middleware feature lands. You have to either bloat every loader, or, if you're using express server, you can add a middleware there (not very pretty). As for why you can't successfully throw the redirect, I don't know. You'd have to share more of your code. |
Beta Was this translation helpful? Give feedback.
-
I use the Express adapter and check for the auth cookie before handing it to Remix. It protects all routes by default. You have to opt-out of the check for public routes. I also check for the user in the loader via the Anyway, here's a sample showing how it works: https://github.com/kiliman/express-auth-example/blob/main/server/index.js |
Beta Was this translation helpful? Give feedback.
-
Thanks, guys. The problem with For now, I've decided to just put Let's see in the future how Remix evolves and better handles horizontal aspects. 🤞 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I'm building an admin application that should be used only by admins. There are no public routes except for the login page.
I cannot find a good way to achieve that. With other web frameworks, I've got middleware and I can wrap everything with an authentication middleware.
What I am doing with Remix is just bloating every
loader
with something like this:I've tried having a
requireUser
method, just like the Jokes tutorial shows, but when I dothrow redirect('/')
I got this error:Even routes that don't need a loader, I still have to define one and return empty json.
I've looked at the
remix-examples
repo, but didn't find anything useful there as well.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions