Skip to content

Commit 44f6639

Browse files
committed
feat: Allow experimental request intereceptor enabling via ENV
INTERCEPT_REQUESTS=true
1 parent 81e721d commit 44f6639

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/utils/InterceptUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BatchInterceptor, HttpRequestEventMap, InterceptorReadyState } from '@m
22
import { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'
33
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'
44
import { nanoid } from 'nanoid';
5-
import { isDebugMode, parseRegexSingleOrFail } from '../utils.js';
5+
import { isDebugMode, parseBool, parseRegexSingleOrFail } from '../utils.js';
66

77
interface InterceptFilterOptions {
88
url?: string | RegExp
@@ -25,6 +25,8 @@ interface InterceptData extends Intercept {
2525
reqId?: string
2626
}
2727

28+
const enabled = isDebugMode() || parseBool(process.env.INTERCEPT_REQUESTS);
29+
2830
const interceptor = new BatchInterceptor({
2931
name: 'global-interceptor',
3032
interceptors: [
@@ -86,7 +88,7 @@ const generateRequestFilter = (opts?: InterceptFilterOptions): RequestFilterFunc
8688
export const interceptRequest = (listenerId?: string, opts?: InterceptFilterOptions): string => {
8789
const lid = listenerId || nanoid();
8890

89-
if(!isDebugMode()) {
91+
if(!enabled) {
9092
return lid;
9193
}
9294

0 commit comments

Comments
 (0)