Request Filtering
Control which requests are captured using path patterns and HTTP methods.
Configuration
withApiSpy({}, {
filter: {
includePaths: ['/api/'],
excludePaths: ['/health', '/metrics'],
methods: ['GET', 'POST', 'PUT', 'DELETE'],
},
});
Options
includePaths
Array of regex patterns. Only requests matching these patterns are captured.
filter: {
includePaths: [
'/api/', // Any path containing /api/
'^/users', // Paths starting with /users
'/orders/\\d+', // /orders/ followed by numbers
],
}
Note
If empty, all paths are included by default.
excludePaths
Array of regex patterns. Matching requests are excluded.
methods
Array of HTTP methods to capture.