Fix WebSocket, add auto refresh on frontend update

This commit is contained in:
2025-06-19 19:08:41 +02:00
parent 34deaa1984
commit eabad4e055
5 changed files with 119 additions and 2 deletions

20
ejs/footer.ejs Normal file
View File

@@ -0,0 +1,20 @@
<script>
let ws;
function connectWebSocket() {
const ws = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + window.location.pathname);
ws.onmessage = async (event) => {
if (event.data === 'update') {
location.reload();
}
};
ws.onclose = () => {
setTimeout(connectWebSocket, 5000);
};
}
connectWebSocket();
</script>