diff --git a/lib/www/client/source/src/components/footer.vue b/lib/www/client/source/src/components/footer.vue
index 39c99eb..7a4a32d 100644
--- a/lib/www/client/source/src/components/footer.vue
+++ b/lib/www/client/source/src/components/footer.vue
@@ -10,7 +10,10 @@
- mdi-cloud-outline
+
+ mdi-cloud-outline
+ mdi-cloud-off
+
mdi-cloud-off
@@ -65,8 +68,20 @@ export default {
...mapState({
serverConnected: state => state.notify.serverConnected,
- isFrontendRemote: state => state.api.serverInfo?.["remote-frontend"] ?? false
+ isFrontendRemote: state => state.api.serverInfo?.["remote-frontend"] ?? false,
+ isGatewayReliable: state => state.api.isGatewayReliable
})
+ },
+
+ watch: {
+
+ isGatewayReliable (val) {
+ if (val === false) {
+ this.$root.showSnack("Gateway error", "warning");
+ }
+ }
+
}
+
};
diff --git a/lib/www/client/source/src/store/modules/api/actions.js b/lib/www/client/source/src/store/modules/api/actions.js
index 3025b0d..3b97559 100644
--- a/lib/www/client/source/src/store/modules/api/actions.js
+++ b/lib/www/client/source/src/store/modules/api/actions.js
@@ -71,7 +71,7 @@ async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb
res = await limiter.enqueue(async () => await fetch(url, init));
}
- if (cache && !isCached) {
+ if (cache && !isCached && res.ok) { // Only cache successful responses
cache.put(url, res.clone());
}
@@ -95,6 +95,12 @@ async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb
return [key, value];
});
state.serverInfo = entries.length ? Object.fromEntries(entries) : {};
+
+ if (state.serverInfo["remote-frontend"]) {
+ state.isGatewayReliable = ![ 502, 503, 504 ].includes(res.status);
+ } else {
+ state.isGatewayReliable = null;
+ }
}
if (res.ok) {
diff --git a/lib/www/client/source/src/store/modules/api/state.js b/lib/www/client/source/src/store/modules/api/state.js
index c12faee..17fd68f 100644
--- a/lib/www/client/source/src/store/modules/api/state.js
+++ b/lib/www/client/source/src/store/modules/api/state.js
@@ -2,7 +2,8 @@ const state = () => ({
apiUrl: "/api",
requestsCount: 0,
maxConcurrent: 15,
- serverInfo: {} // Contents of the last received X-Dougal-Server HTTP header
+ serverInfo: {}, // Contents of the last received X-Dougal-Server HTTP header
+ isGatewayReliable: null, // True if we start seeing HTTP 502‒504 responses
});
export default state;