Skip to main content

Frontend engineering · Frameworks

Middleware

Also called: Request middleware, Edge middleware, Gateway hooks

Logic that runs before a request hits a page or API—often for auth, redirects, rewrites, or injecting headers.

In detail

Middleware is a gate: requests pass here first. Next.js middleware/proxy, Express middleware, and many BFF gateways share the idea.

Good fits: redirect when logged out, geo rewrites, simple A/B, security headers. Bad fits: heavy business work—this path is hot and should stay fast.

Gatekeeping isn't your domain service: pricing and orders still belong in backend services.

Developer info
Term ID
eng-middleware
DOM selectors
No DOM cues. This concept isn't detected directly on a page.
Priority
1 · when several match at the same level, the higher priority wins
Version
v1 · updated Oct 5, 2026