Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
ipFilter()
Allow or deny requests by client IP, with 403 for anything blocked.
Use case
Some surfaces should not be open to the whole internet: an admin panel, an internal dashboard, a webhook that only one provider calls. An IP filter restricts access to a known set of addresses, or blocks a set of known-bad ones, without touching your auth logic.
How it works
It reads req.ip and checks the deny list first (a match is rejected immediately), then the allow
list (if set, only listed IPs pass; everyone else is rejected). A blocked request replies 403 Forbidden; an
allowed one calls next().
Configuration
| Option | Default | Notes |
|---|---|---|
allow | null | If set, only these IPs pass. |
deny | [] | These IPs are always rejected (checked before allow). |
Example
Notes
Behind a proxy, make sure
req.ipreflects the real client (the proxy must forward it), otherwise you are filtering the proxy's own IP and either letting everyone through or blocking everyone. IP allow-lists are a useful extra layer, not a replacement for authentication.
Next: safePath.