Skip to content

Commit 7888f19

Browse files
authored
FS: custom domain error message (grafana#113779)
1 parent c7e8291 commit 7888f19

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

pkg/services/frontend/index.html

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"Segoe UI Symbol";
8282
}
8383

84-
.fs-variant-loader, .fs-variant-error {
84+
.fs-variant-loader, .fs-variant-error, .fs-custom-domain-error {
8585
display: contents;
8686
}
8787

@@ -118,6 +118,10 @@
118118
opacity: 1;
119119
}
120120

121+
.fs-custom-domain-error .fs-loader-text {
122+
opacity: 1;
123+
}
124+
121125
.fs-error-icon {
122126
fill: var(--fs-color-error);
123127
}
@@ -151,6 +155,20 @@
151155

152156
<p class="fs-loader-text">Error loading Grafana</p>
153157
</div>
158+
<div class="fs-custom-domain-error fs-hidden">
159+
<svg
160+
width="32"
161+
height="32"
162+
class="fs-error-icon"
163+
viewBox="0 0 24 24"
164+
xmlns="http://www.w3.org/2000/svg"
165+
>
166+
<path d="M12,14a1.25,1.25,0,1,0,1.25,1.25A1.25,1.25,0,0,0,12,14Zm0-1.5a1,1,0,0,0,1-1v-3a1,1,0,0,0-2,0v3A1,1,0,0,0,12,12.5ZM12,2A10,10,0,1,0,22,12,10.01114,10.01114,0,0,0,12,2Zm0,18a8,8,0,1,1,8-8A8.00917,8.00917,0,0,1,12,20Z"/>
167+
</svg>
168+
169+
<p class="fs-loader-text">Error loading Grafana</p>
170+
<p class="fs-loader-text">Please, use your URL custom domain directly</p>
171+
</div>
154172
</div>
155173

156174
<div id="reactRoot"></div>
@@ -185,6 +203,14 @@
185203
console.error('Failed to report boot error to backend: ', err);
186204
});
187205
};
206+
// Needed to stop retrying boot data when custom domain error occurs
207+
// TODO remove when https://github.com/grafana/grafana/pull/113717 is released in backend
208+
const CUSTOM_DOMAIN_ERROR = "Custom domain error";
209+
window.__grafana_custom_domain_failed = function(err) {
210+
console.error('Failed to load Grafana due to custom domain issue', err);
211+
document.querySelector('.fs-variant-loader').classList.add('fs-hidden');
212+
document.querySelector('.fs-custom-domain-error').classList.remove('fs-hidden');
213+
}
188214

189215
window.onload = function() {
190216
if (window.__grafana_app_bundle_loaded) {
@@ -219,8 +245,12 @@
219245
bootDataUrl.searchParams.append(key, value);
220246
}
221247

222-
const resp = await fetch(bootDataUrl);
223-
248+
const resp = await fetch(bootDataUrl, {redirect: 'manual'});
249+
// TODO remove when https://github.com/grafana/grafana/pull/113717 is released in backend
250+
if (resp.type === 'opaqueredirect') {
251+
window.__grafana_custom_domain_failed();
252+
return CUSTOM_DOMAIN_ERROR;
253+
}
224254
// manual redirect for custom domains
225255
// see pkg/middleware/validate_host.go
226256
if (resp.status === 204) {
@@ -265,6 +295,9 @@
265295
setLoading();
266296
setTimeout(attemptFetch, CHECK_INTERVAL);
267297
return;
298+
// TODO remove when https://github.com/grafana/grafana/pull/113717 is released in backend
299+
} else if (bootData === CUSTOM_DOMAIN_ERROR) {
300+
return;
268301
}
269302

270303
resolve(bootData);

0 commit comments

Comments
 (0)