How to Bypass Rate Limiting for Admin in a Custom Directus Extension

Hi everyone! :waving_hand:

I want regular users to be limited as expected, but I’d like admin users (or users with specific roles) to bypass the rate limit altogether.

I’m aware that Directus has built-in rate limiting, but I’d like to know how I can conditionally skip the limiter based on the user role — ideally from within a custom hook in a Directus extension.

Has anyone done something similar?
Is there a recommended way to check the user role and bypass the limiter inside a custom extension?

Any help or examples would be greatly appreciated!

Thanks :folded_hands:

I found that rate limiting in Directus is handled by Express middleware, so the accountability object (with user role) isn’t available yet.

Is there a hook or way to override this middleware so I can implement a custom rate limiter that checks for a special header like X-BYPASS-RATE-LIMIT with a token to bypass the limit?

Thanks :flexed_biceps:t2: