Skip to main content
The ApiTraffic Web Application Firewall runs inside your application and inspects inbound requests before they reach your route handlers. Policies are managed in ApiTraffic and pushed to connected application instances automatically. The WAF is an optional addition to an existing ApiTraffic framework integration. It supports Express, Fastify, Koa, and Hapi.

Install

Add the middleware

Register the WAF after ApiTraffic and any middleware that parses request bodies, but before your routes. This lets the WAF inspect parsed request data and stop blocked requests before your application handles them.
Middleware order matters. The WAF must run before your route handlers to prevent blocked requests from reaching application code.

Create a policy

  1. Open WAF in the ApiTraffic dashboard.
  2. Select Add WAF Policy.
  3. Choose the environments and buckets the policy protects.
  4. Start in Monitor mode. Matching requests continue normally while you review detections in WAF → Insights.
  5. Change the policy to Enforcing when you are ready to block matching requests.
Policy changes are delivered to connected servers automatically. You do not need to redeploy your application when you tune a policy or change its mode.

Verify

  1. Start your application and send normal traffic through a protected endpoint.
  2. Open WAF → Insights and confirm that the application is reporting WAF activity.
  3. Review detections while the policy is in Monitor mode before switching to Enforcing.

Disable the WAF locally

Set the environment variable below as an emergency, process-level kill switch:
.env
You can also disable it in code:
Both options make the middleware pass requests through without evaluating the active policy.