SDK Middleware
The Requexa SDK is an optional Next.js middleware that captures live HTTP traffic in your development environment. It enriches your manifest with real request examples — actual payloads, headers, and response shapes from running code.
NODE_ENV on every request and returns immediately in production — no overhead, no data leakage, nothing shipped to users.Installation
Install it as a regular dependency (not devDependency) since your Next.js build needs to import it. The production guard is handled at runtime, not at build time.
Setup
Two files to add or update:
1. Wrap your middleware
If you don't have a middleware.ts yet, create one. If you already have one, wrap your existing export:
2. Add the capture route handler
Create a new API route that exposes the captured requests to Requexa:
3. Add the secret to your env
/api/requexa route so only the Requexa platform can read your captured traffic. Use a strong random string: openssl rand -base64 32Viewing Captured Requests
Once the SDK is set up, use your app normally in development. Every API request that passes through your middleware is captured in an in-memory ring buffer (500 entries max, oldest discarded first).
The Requexa platform can poll this buffer via the GET /api/requexa endpoint to pull real examples and enrich your workspace. Future versions will provide a UI to browse and replay captured requests directly.
Security & Sanitization
The SDK automatically sanitizes sensitive values before storing them in the ring buffer. Fields matching these patterns are redacted to [REDACTED]:
- Field names containing:
password,token,secret,apikey,api_key - Values matching credit card patterns (16-digit numbers)
- Values matching SSN patterns (XXX-XX-XXXX)
- Authorization header values (Bearer tokens, Basic credentials)
/api/requexa route) to production — the production guard in the middleware handles this, but defence-in-depth is good practice.