fix: harden rate limiting behind proxies - #93
Merged
Conversation
Only trust proxy forwarding data when the deployment explicitly configures how many hops are safe. This keeps client IP handling predictable and prevents request headers from widening the limiter scope by accident. • Bound request-derived limiter state so untrusted traffic cannot grow in-memory buckets without limit • Document the trusted-proxy setting and cover the behavior with env, middleware, and API tests
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 89.33% 91.21% +1.87%
==========================================
Files 12 12
Lines 300 330 +30
Branches 71 86 +15
==========================================
+ Hits 268 301 +33
+ Misses 16 11 -5
- Partials 16 18 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Bug Fixes
Tests
Documentation
Test plan
RUN v4.1.11 /Users/loganlindquist/Web/semantic-docs
Coverage enabled with v8
Test Files 11 passed (11)
Tests 178 passed (178)
Start at 22:31:45
Duration 3.23s (transform 607ms, setup 0ms, import 1.32s, tests 2.49s, environment 3.93s)
% Coverage report from v8
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 96.38 | 89.63 | 98.73 | 96.54 |
components | 95.5 | 90.19 | 95.45 | 95.45 |
Search.tsx | 95.18 | 89.36 | 94.73 | 95.12 | 119,124,247-248
lib | 98.03 | 90 | 100 | 98.93 |
env.ts | 96.42 | 90.62 | 100 | 96.29 | 31
markdown.ts | 96.77 | 77.27 | 100 | 100 | 13,48,57-58
middleware | 100 | 94.23 | 100 | 100 |
rateLimit.ts | 100 | 94.23 | 100 | 100 | 83,125,142
pages/api | 89.28 | 82.05 | 100 | 89.09 |
search.json.ts | 89.28 | 82.05 | 100 | 89.09 | 111,200,213-216
-------------------|---------|----------|---------|---------|-------------------
=============================== Coverage summary ===============================
Statements : 96.38% ( 320/332 )
Branches : 89.63% ( 199/222 )
Functions : 98.73% ( 78/79 )
Lines : 96.54% ( 307/318 )
================================================================================ (178 passed; 96.54% lines; limiter 100% lines)
[2026-08-24T03:31:50.266Z] INFO: Initializing database schema...
[2026-08-24T03:31:50.266Z] INFO: Created articles_local_384 with 384-dimension embeddings
[2026-08-24T03:31:50.266Z] INFO: Database schema initialized successfully!
[2026-08-24T03:31:51.387Z] INFO: Starting content indexing...
[2026-08-24T03:31:51.394Z] INFO: [1/3] Indexing: features/semantic-search.md
Loading local embedding model (Xenova/all-MiniLM-L6-v2)...
Local model loaded successfully
[2026-08-24T03:31:51.775Z] INFO: [2/3] Indexing: getting-started/welcome.md
[2026-08-24T03:31:51.800Z] INFO: [3/3] Indexing: theme/overview.md
[2026-08-24T03:31:51.834Z] INFO: Indexing complete!
[2026-08-24T03:31:51.834Z] INFO: Successfully indexed 3/3 documents
22:31:53 [types] Generated 29ms
22:31:53 [build] output: "server"
22:31:53 [build] mode: "server"
22:31:53 [build] directory: /Users/loganlindquist/Web/semantic-docs/dist/
22:31:53 [build] adapter: @astrojs/node
22:31:53 [build] Collecting build info...
22:31:53 [build] ✓ Completed in 70ms.
22:31:53 [build] Building server entrypoints...
22:31:53 [vite] ✓ built in 176ms
22:31:53 [vite] ✓ built in 108ms
22:31:54 [vite] ✓ built in 164ms
prerendering static routes
[ELIFECYCLE] Command failed with exit code 1.
Closes #76