From c0ba9e4b64f233c2733a8c5e904a8536ae37eb42 Mon Sep 17 00:00:00 2001 From: Jonas Gloning <34194370+jonasgloning@users.noreply.github.com> Date: Tue, 17 May 2022 13:57:07 +0200 Subject: [PATCH] fix(referrerPolicy): you can now set a custom referrerPolicy for api requests Fixes #955 --- lib/api.ts | 2 +- lib/optionInterfaces.ts | 1 + lib/peer.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/api.ts b/lib/api.ts index 174dc97f2..c4abc7ffb 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -14,7 +14,7 @@ export class API { url.searchParams.set("ts", `${Date.now()}${Math.random()}`); url.searchParams.set("version", version); return fetch(url.href, { - referrerPolicy: "strict-origin-when-cross-origin", + referrerPolicy: this._options.referrerPolicy, }); } diff --git a/lib/optionInterfaces.ts b/lib/optionInterfaces.ts index ee91885cd..934783d99 100644 --- a/lib/optionInterfaces.ts +++ b/lib/optionInterfaces.ts @@ -11,6 +11,7 @@ export interface PeerJSOption { token?: string; config?: RTCConfiguration; debug?: number; + referrerPolicy?: ReferrerPolicy; } export interface PeerConnectOption { diff --git a/lib/peer.ts b/lib/peer.ts index 2f4b2c0b2..60e49567f 100644 --- a/lib/peer.ts +++ b/lib/peer.ts @@ -29,6 +29,7 @@ class PeerOptions implements PeerJSOption { config?: any; secure?: boolean; pingInterval?: number; + referrerPolicy?: ReferrerPolicy; logFunction?: (logLevel: LogLevel, ...rest: any[]) => void; } @@ -164,6 +165,7 @@ export class Peer extends EventEmitter { key: Peer.DEFAULT_KEY, token: util.randomToken(), config: util.defaultConfig, + referrerPolicy: "strict-origin-when-cross-origin", ...options, }; this._options = options;