Skip to content

Commit d63ad75

Browse files
fix(frontend): Use port 443 as default to connect to flagd if https is in use
1 parent 11ef3c6 commit d63ad75

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/frontend/pages/_app.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,19 @@ if (typeof window !== 'undefined') {
3737
* We connect to flagd through the envoy proxy, straight from the browser,
3838
* for this we need to know the current hostname and port.
3939
*/
40+
41+
const useTLS = window.location.protocol === 'https:';
42+
let port = useTLS ? 443 : 80;
43+
if (window.location.port) {
44+
port = parseInt(window.location.port, 10);
45+
}
46+
4047
OpenFeature.setProvider(
4148
new FlagdWebProvider({
4249
host: window.location.hostname,
4350
pathPrefix: 'flagservice',
44-
port: window.location.port ? parseInt(window.location.port, 10) : 80,
45-
tls: window.location.protocol === 'https:',
51+
port: port,
52+
tls: useTLS,
4653
maxRetries: 3,
4754
maxDelay: 10000,
4855
})

0 commit comments

Comments
 (0)