Skip to content

Middleware

Direct answer

What is Middleware?

Short definition

Middleware is code that runs before or after a request reaches the main app logic. It can check logins, limit requests, add headers, or block unsafe traffic.

Why it matters
Middleware keeps common request rules in one place. That makes controllers cleaner and helps protect the app.

How teams use Middleware

Use this term when you need to describe the practical role it plays in a software project.

Common use cases

  • Authenticating users before allowing access
  • Logging all incoming requests
  • Handling CORS for API requests
  • Rate limiting to prevent abuse

Examples of Middleware

These examples show the term in everyday product, platform, or operations work.

Real-world examples

  • Auth middleware redirecting unauthenticated users to login
  • API middleware adding CORS headers to responses
  • Log middleware recording request duration and response codes

Related terms