Skip global middleware for certain serverFns?
Hello! I'm building an application that has a couple publicly accessible pages and a bunch of pages behind a login.
I'd like to add an authorization check for my server functions via middleware. My hope is that I could register it as global middleware and then somehow just skip it for the server functions that populate my publicly accessible pages—that way rather than remembering to add the authorization middleware to server functions, I'll be forced to specifically add public server functions to an allow list (or something like that).
Is there way to do this, or is there a better way I could be approaching this?
2 Replies
other-emerald•4mo ago
hmm i dont think that's really possible right now
we want to allow abstractions on top of createServerFn in the future, which will allow you define e.g. a createAuthenticatedServerFn and then you would use that only in places where you need auth
conscious-sapphireOP•4mo ago
That would be really neat! Thanks for the response, for now I'll just make sure it's added to all the non-public serverFns.