Skip to content

Commit c77f8d8

Browse files
fix: GOFF Authorize connecting in a secure way to the websocket (#625)
1 parent 8fac8cb commit c77f8d8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

libs/providers/go-feature-flag-web/src/lib/go-feature-flag-web-provider.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class GoFeatureFlagWebProvider implements Provider {
5252
// _flags is the in memory representation of all the flags.
5353
private _flags: { [key: string]: ResolutionDetails<FlagValue> } = {};
5454

55-
5655
constructor(options: GoFeatureFlagWebProviderOptions, logger?: Logger) {
5756
this._logger = logger;
5857
this._apiTimeout = options.apiTimeout || 0; // default is 0 = no timeout
@@ -93,7 +92,7 @@ export class GoFeatureFlagWebProvider implements Provider {
9392
const wsURL = new URL(this._endpoint);
9493
wsURL.pathname =
9594
wsURL.pathname.endsWith('/') ? wsURL.pathname + this._websocketPath : wsURL.pathname + '/' + this._websocketPath;
96-
wsURL.protocol = "ws"
95+
wsURL.protocol = wsURL.protocol === 'https:' ? 'wss' : 'ws';
9796

9897
// adding API Key if GO Feature Flag use api keys.
9998
if(this._apiKey){
@@ -102,7 +101,7 @@ export class GoFeatureFlagWebProvider implements Provider {
102101

103102
this._logger?.debug(`${GoFeatureFlagWebProvider.name}: Trying to connect the websocket at ${wsURL}`)
104103

105-
this._websocket = new WebSocket(wsURL, ["ws", "http", "https"]);
104+
this._websocket = new WebSocket(wsURL);
106105
await this.waitWebsocketFinalStatus(this._websocket);
107106

108107
this._websocket.onopen = (event) => {

0 commit comments

Comments
 (0)