From 1a28f001f7f51a7b6f3baf5830724234cb1600ca Mon Sep 17 00:00:00 2001 From: Sven Kirschbaum Date: Mon, 17 Jun 2024 22:52:54 +0200 Subject: [PATCH] fix(frontend): Use port 443 as default to connect to flagd if https is in use --- src/frontend/pages/_app.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/frontend/pages/_app.tsx b/src/frontend/pages/_app.tsx index 00a7e696b5..e49b51f7c6 100755 --- a/src/frontend/pages/_app.tsx +++ b/src/frontend/pages/_app.tsx @@ -37,12 +37,19 @@ if (typeof window !== 'undefined') { * We connect to flagd through the envoy proxy, straight from the browser, * for this we need to know the current hostname and port. */ + + const useTLS = window.location.protocol === 'https:'; + let port = useTLS ? 443 : 80; + if (window.location.port) { + port = parseInt(window.location.port, 10); + } + OpenFeature.setProvider( new FlagdWebProvider({ host: window.location.hostname, pathPrefix: 'flagservice', - port: window.location.port ? parseInt(window.location.port, 10) : 80, - tls: window.location.protocol === 'https:', + port: port, + tls: useTLS, maxRetries: 3, maxDelay: 10000, })