fix: exclude UI static assets from rate limiting BED-8327#2816
fix: exclude UI static assets from rate limiting BED-8327#2816elikmiller wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR adjusts the registration of UI static asset routes by moving the static handler outside the default API rate limiter middleware block. Previously, the route was mounted using a hardcoded path within the middleware wrapper; it is now registered separately with the configured UI path constant, removing rate limiting from static asset serving. ChangesUI Static Asset Routing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fe4d9c7 to
1f760cb
Compare
1f760cb to
fe4d9c7
Compare
fe4d9c7 to
0cb1063
Compare
Description
Move the
/uistatic asset prefix out of theDefaultRateLimitMiddlewaregroup inRegisterFossRoutesso a single UI page load — which can request many HTML/JS/CSS/media assets — is not throttled by the per-IP API rate limiter. While reordering, also switch the literal"/ui"to the existingapi.UserInterfacePathconstant to keep the path defined in one place.Auth and other global middleware (panic handler, auth middleware, compression, logging) continue to apply, since those are registered via
UsePrerouting/UsePostroutingrather than the per-routerouter.With(...)rate-limiter wrapper.Motivation and Context
Resolves BED-8327
Users have reported intermittent missing images and 429s on remediation pages with heavy screenshots (e.g. ESC1 documentation). The static asset route was previously inside the default rate-limited group, which trips the limiter whenever the UI fetches many assets at once — especially when react-query refetches on tab focus.
This PR handles the static asset / UI path. The companion change in
bloodhound-enterprisecovers the/api/v2/assetsBHE finding-asset prefix and the UI-siderefetchOnWindowFocus/ memoization fixes.How Has This Been Tested?
cmd/api/src/api/middleware/rate_limit_test.goalready cover the rate-limiter middleware itself (TestRateLimitMiddleware,TestDefaultRateLimitMiddleware). This PR only changes route registration, not the middleware, so no new middleware tests were added.just prepare-for-codereview— clean tree, no codegen / license / format drift.Screenshots (optional):
n/a
Types of changes
Checklist:
Summary by CodeRabbit