Middleware should run even if there is no loader #12950
infiniteluke
started this conversation in
Proposals
Replies: 1 comment
-
I agree that middlewares should run regardless if the route has a loader or not, at least of routes behind the umbrella of the the middleware, so if you add a middleware in root every route will be under that middleware, but if you add it to a layout route other routes not nested inside should not trigger it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The soon to ship middleware feature is currently coupled to the need to run a loader/action. So, routes without a loader will not participate in middleware. This is problematic for routes that do not have a loader for many valid reasons. One example: I want to continue to use
useQuery
in a route or don't have time to migrate, but I still want to protect that route with an auth middleware.In my custom implementation of middleware in
dataStrategy
, I have to addloader: () => null
to routes that I want to "force" into the middleware matching. This is not obvious and is a confusing DX/API. It also creates cruft on a bunch of routes that haven't been converted to use loaders yet.Should middleware opt a route into the dataStrategy/revalidation?
Beta Was this translation helpful? Give feedback.
All reactions