Skip to content

Commit 08c2e80

Browse files
committed
fix: assigning endpoint to the search params
1 parent ac079e3 commit 08c2e80

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
with:
3131
folder: ./.eodash/dist/
3232
branch: gh-pages
33-
clean-exclude: pr-preview
33+
clean-exclude: pr-preview

src/main.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,24 @@ function assignStacEndpoint() {
174174
const stacEndpoint = urlParams.get("stacEndpoint");
175175

176176
if (stacEndpoint && stacEndpoint.endsWith("catalog.json")) {
177+
console.log(
178+
"[eodash-preview-instance] assigned stacEndpoint:",
179+
stacEndpoint,
180+
);
181+
177182
return /** @type {`${string}/catalog.json`} */ (stacEndpoint);
178183
}
179184

180-
console.warn(
181-
"[eodash-preview-instance] stacEndpoint not assigned, using default",
182-
);
183185
if (window.parent !== window) {
184186
const message = {
185187
type: "eodash:loaded",
186188
endpoint: new URL(window.location.href).searchParams.get("stacEndpoint"),
187189
};
188190
window.parent.postMessage(message, "*");
189191
}
192+
console.warn(
193+
"[eodash-preview-instance] stacEndpoint not assigned, using default",
194+
);
190195
return "https://esa-eodashboards.github.io/eodashboard-catalog/trilateral/catalog.json";
191196
}
192197

@@ -197,10 +202,11 @@ window.addEventListener("message", (event) => {
197202
break;
198203

199204
case "eodash:stacEndpoint":
200-
const stacEndpoint = event.data.endpoint;
205+
const stacEndpoint = event?.data.endpoint;
201206
console.log("stacEndpoint from parent:", stacEndpoint);
202207
if (stacEndpoint && stacEndpoint.endsWith("catalog.json")) {
203208
const urlParams = new URLSearchParams(window.location.search);
209+
urlParams.set("stacEndpoint", stacEndpoint);
204210
window.history.replaceState({}, "", `?${urlParams}`);
205211
window.location.reload();
206212
console.log(

0 commit comments

Comments
 (0)