Skip to content

Commit

Permalink
fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
klucsik committed May 14, 2024
1 parent 856b281 commit 3b1f12a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ the release.
([#1556](https://github.com/open-telemetry/opentelemetry-demo/pull/1556))
* [frontend] Slowloading of images based on imageSlowLoad flag
([#1515](https://github.com/open-telemetry/opentelemetry-demo/pull/1486))
* [frontend] Fix imageloading issues on optimized images. bump next.js version to 13.5.1
* [frontend] Fix imageloading issues on optimized images. bump next.js version
([#1571](https://github.com/open-telemetry/opentelemetry-demo/pull/1571))

## 1.9.0

* [chore] docker compose: add container name as tag attribute to container logs
Expand Down
34 changes: 18 additions & 16 deletions src/frontend/utils/imageLoader.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* We connect to imageprovider through the envoy proxy, straight from the browser, for this we need to know the current hostname and port.
* During building and serverside rendering, these are undefined so we use some conditionals and default values.
*/
let hostname = "localhost";
let port = 8080;
let protocol = "http";
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
/*
* We connect to imageprovider through the envoy proxy, straight from the browser, for this we need to know the current hostname and port.
* During building and serverside rendering, these are undefined so we use some conditionals and default values.
*/
let hostname = "localhost";
let port = 8080;
let protocol = "http";

if (typeof window !== "undefined" && window.location) {
hostname = window.location.hostname;
port = window.location.port ? parseInt(window.location.port, 10) : (window.location.protocol === "https:" ? 443 : 80);
protocol = window.location.protocol.slice(0, -1); // Remove trailing ':'
}
if (typeof window !== "undefined" && window.location) {
hostname = window.location.hostname;
port = window.location.port ? parseInt(window.location.port, 10) : (window.location.protocol === "https:" ? 443 : 80);
protocol = window.location.protocol.slice(0, -1); // Remove trailing ':'
}

export default function imageLoader({ src, width, quality }) {
// We pass down the optimization request to the iamgeprovider service here, without this, nextJs would try to use internal optimizer which is not working with the external imageprovider.
return `${protocol}://${hostname}:${port}/${src}?w=${width}&q=${quality || 75}`
}
export default function imageLoader({ src, width, quality }) {
// We pass down the optimisation request to the imageprovider service here, without this, nextJs would try to use internal optimiser which is not working with the external imageprovider.
return `${protocol}://${hostname}:${port}/${src}?w=${width}&q=${quality || 75}`
}

0 comments on commit 3b1f12a

Please sign in to comment.