TanStackT
TanStack9mo ago
3 replies
verbal-lime

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?
Was this page helpful?