network proxy: prevent referring to window object on import, fixes #2742
This commit is contained in:
parent
f321ffbdda
commit
769d8851bb
2 changed files with 3 additions and 2 deletions
|
|
@ -74,7 +74,7 @@ export class BeaconProxyHandler<T extends typeof navigator.sendBeacon> implement
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class BeaconProxy {
|
export default class BeaconProxy {
|
||||||
public static origSendBeacon = window?.navigator?.sendBeacon
|
public static origSendBeacon = typeof window !== 'undefined' ? window.navigator?.sendBeacon : undefined
|
||||||
|
|
||||||
public static hasSendBeacon() {
|
public static hasSendBeacon() {
|
||||||
return !!BeaconProxy.origSendBeacon
|
return !!BeaconProxy.origSendBeacon
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export default function createNetworkProxy(
|
||||||
},
|
},
|
||||||
tokenUrlMatcher?: (url: string) => boolean,
|
tokenUrlMatcher?: (url: string) => boolean,
|
||||||
): void {
|
): void {
|
||||||
|
if (!context) return;
|
||||||
if (modules.xhr) {
|
if (modules.xhr) {
|
||||||
if (context.XMLHttpRequest) {
|
if (context.XMLHttpRequest) {
|
||||||
context.XMLHttpRequest = XHRProxy.create(
|
context.XMLHttpRequest = XHRProxy.create(
|
||||||
|
|
@ -83,7 +84,7 @@ export default function createNetworkProxy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (modules.beacon) {
|
if (modules.beacon) {
|
||||||
if (context?.navigator?.sendBeacon) {
|
if (context.navigator?.sendBeacon) {
|
||||||
context.navigator.sendBeacon = BeaconProxy.create(
|
context.navigator.sendBeacon = BeaconProxy.create(
|
||||||
ignoredHeaders,
|
ignoredHeaders,
|
||||||
setSessionTokenHeader,
|
setSessionTokenHeader,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue