Skip to content

Commit

Permalink
fix(frontend): Use port 443 as default to connect to flagd if https i…
Browse files Browse the repository at this point in the history
…s in use (open-telemetry#1609)

* fix(frontend): Use port 443 as default to connect to flagd if https is in use

* chore: Update CHANGELOG.md

---------

Co-authored-by: Pierre Tessier <[email protected]>
  • Loading branch information
2 people authored and ahealy-newr committed Jul 24, 2024
1 parent 888c159 commit c7f2445
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ the release.
([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610))
* [Valkey] Replace Redis with Valkey
([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619))
* [frontend] fixed default flagd port for HTTPS connections
([#1609](https://github.com/open-telemetry/opentelemetry-demo/pull/1609))

## 1.10.0

Expand Down
11 changes: 9 additions & 2 deletions src/frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down

0 comments on commit c7f2445

Please sign in to comment.