fix: cache public assets and safe SWR APIs at the edge#497
fix: cache public assets and safe SWR APIs at the edge#497kasperpawlowski wants to merge 2 commits into
Conversation
|
🚅 Deployed to the euler-lite-pr-497 environment in euler-lite
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: euler-xyz/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe PR expands ChangesCache Configuration Rules
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Ports the cache rules onto the current proxy routes and keeps sensitive/error responses no-store.
cf7e948 to
962946c
Compare
LeonardEulerXYZ
left a comment
There was a problem hiding this comment.
Leonard review — PR #497
Verdict: COMMENT — no blocking findings found.
Reviewed head: 962946c4cd0796fcc424848b37d0770007725737
Scope reviewed:
nuxt.config.tsroute rules for static assets, public/SWR API paths, and strict fallbackno-store.server/plugins/cache-error-responses.tsno-store guard for error responses and sensitive/live paths.tests/server/cache-error-responses.test.tscoverage for error and sensitive-path behavior.- Existing reward/public API handlers around the newly cached paths, to check that user/account-specific endpoints remain outside the edge-cache set.
Validation performed:
npx eslint nuxt.config.ts server/plugins/cache-error-responses.ts tests/server/cache-error-responses.test.tsnpm run test:run -- tests/server/cache-error-responses.test.ts— 11 tests passed.npm run build— completed successfully.git diff --check- Built-server API/header smoke:
/remainsno-store./logo.svgand/favicons/favicon.icoreceive public static-asset cache headers./api/token-list?chainId=1,/api/euler-chains, and/api/public/metadata?...receive the intended browser cache + CDN SWR headers locally.- Invalid
/api/token-list?...error responses are forced back tono-store. /api/screen-addressand/api/rpc/1remainno-store.
- Railway preview spot-check confirmed the same browser-facing
Cache-Controlbehavior for representative HTML/static/API/error paths. CDN-specific headers are not visible on that preview host, so I treated the local Nitro build as the source for those origin headers. - Light headed Chromium/Xvfb desktop + mobile load smoke of
/confirmed the app shell renders. Browser smoke only; no wallet/signing coverage.
Scalability / maintainability hygiene pass:
- The change is centralized in route rules plus one Nitro guard plugin rather than one-off per-handler patches.
- I checked sibling public API and reward proxy handlers against the cache boundary: public list-style endpoints are explicitly cached; account/proof/subgraph/RPC/Tenderly/screening paths remain on fallback or plugin-enforced
no-store. - No missed sibling route or duplicated old behavior found. The remaining repeated cache-header literals in
nuxt.config.tsare verbose but localized configuration, not a correctness issue in this PR.
Bot feedback reviewed:
- No active inline CodeRabbit findings were present.
- CodeRabbit's walkthrough uses some stale/imprecise route names for the rewards/intrinsic-APY surface, but I did not find an actionable code issue behind that wording.
Screenshots:
- Not posted; this PR changes cache/header behavior rather than a visual UI surface, so API/header smoke was the useful evidence.
Separates error response cache protection from sensitive route cache protection and normalizes sensitive paths before matching.
LeonardEulerXYZ
left a comment
There was a problem hiding this comment.
Leonard review — PR #497
Verdict: COMMENT — no blocking findings found.
Reviewed head: a171e36580226d8268c965e3aaa228f37e480011
Scope reviewed:
nuxt.config.tsroute rules for long-lived public assets, SWR-friendly public APIs, and fallbackno-store.server/plugins/cache-error-responses.ts,server/plugins/sensitive-route-cache.ts, andserver/utils/cache-headers.tsfor layered no-store protection on errors and sensitive/live routes.- Focused tests for error-response and sensitive-path cache behavior.
- Surrounding public/reward/API proxy handlers to verify which endpoints are shared public data versus account-specific or freshness-sensitive data.
Validation performed:
npx eslint nuxt.config.ts server/plugins/cache-error-responses.ts server/plugins/sensitive-route-cache.ts server/utils/cache-headers.ts tests/server/cache-error-responses.test.ts tests/server/sensitive-route-cache.test.ts— passed.npm run test:run -- tests/server/cache-error-responses.test.ts tests/server/sensitive-route-cache.test.ts— 16 tests passed.npm run build— passed; only existing bundle/chunk-size style warnings observed.git diff --check— passed.- Local built-server header smoke covered representative static, public, error, and sensitive paths:
/staysno-store./logo.svgand/favicons/favicon.icoreceive public static-asset cache headers./api/euler-chains,/api/public/metadata?chainId=1, and/api/token-list?chainId=1receive the intended public browser/CDN cache headers.- Invalid
/api/token-list?chainId=badis forced tono-store. /api/rpc/1,/api/proxy/subgraph/1,/api/screen-address,/api/pyth/updates, user Merkl rewards including trailing slash, Fuul claimable rewards, Incentra proofs, and Turtle proof paths are forced tono-store.- Shared reward endpoints such as Fuul incentives and Incentra Euler campaigns keep the intended public cache headers.
- Railway preview header smoke confirmed the same representative browser/origin headers for HTML, static, public API, error, RPC, and trailing-slash user Merkl reward paths.
- Light headed Chromium/Xvfb desktop and mobile load smoke of
/on the preview confirmed the real app shell renders with no page errors. Browser smoke only; no wallet/signing coverage.
Scalability / maintainability hygiene pass:
- The fix is centralized in route rules plus small Nitro plugins and a shared
forceNoStoreCacheHeadershelper, rather than one-off per-handler patches. - I searched sibling server API handlers that set or depend on cache headers. The cached route set matches the public/list-style handlers; account-specific, proof, RPC, screening, subgraph, Pyth, Tenderly, and Turtle paths remain covered by fallback or plugin-enforced
no-store. - The split of sensitive-route handling into its own plugin is cleaner than overloading the error-response plugin, and the added trailing-slash tests cover the edge that could otherwise leak back to route-rule headers.
- No missed sibling surface found. If this cache matrix grows further, the repeated literal header objects in
nuxt.config.tsare a candidate for named constants/table-driven config, but I would not block this PR on that.
Bot/reviewer feedback reviewed:
- No active inline CodeRabbit findings were present on the current head.
- CodeRabbit’s generated summary is broad but non-actionable; I did not find a material bot claim that needs correction.
Screenshots:
- Not posted. This PR changes cache/header behavior rather than a visual UI surface, so API/header smoke is the relevant evidence. Mobile coverage was a headed app-shell load check, not a visual regression pass.
Summary
Safety
no-storeheaders.no-storeat both browser and edge layers, including normalized trailing-slash paths.Validation
npx eslint nuxt.config.ts server/plugins/cache-error-responses.ts server/plugins/sensitive-route-cache.ts server/utils/cache-headers.ts tests/server/cache-error-responses.test.ts tests/server/sensitive-route-cache.test.tsnpm run test:run -- tests/server/cache-error-responses.test.ts tests/server/sensitive-route-cache.test.tsgit diff --checknpm run build127.0.0.1:3027for trailing-slash sensitive reward routes returningCache-Control,CDN-Cache-Control, andCloudflare-CDN-Cache-Controlasno-store.Summary by CodeRabbit