diff --git a/kinode/packages/settings/pkg/ui/script.js b/kinode/packages/settings/pkg/ui/script.js index c61d9f6d..967ff4e0 100644 --- a/kinode/packages/settings/pkg/ui/script.js +++ b/kinode/packages/settings/pkg/ui/script.js @@ -2,16 +2,11 @@ const APP_PATH = '/settings:settings:sys/ask'; // Fetch initial data and populate the UI function init() { - fetch('/our') - .then(response => response.text()) + fetch(APP_PATH) + .then(response => response.json()) .then(data => { - const our = data + '@settings:settings:sys'; - fetch(APP_PATH) - .then(response => response.json()) - .then(data => { - console.log(data); - populate(data); - }); + console.log(data); + populate(data); }); } @@ -158,7 +153,8 @@ document.getElementById('ping-peer').addEventListener('submit', (e) => { }) // Setup WebSocket connection -const ws = new WebSocket("ws://" + location.host + "/settings:settings:sys/"); +const wsProtocol = location.protocol === 'https:' ? 'wss://' : 'ws://'; +const ws = new WebSocket(wsProtocol + location.host + "/settings:settings:sys/"); ws.onmessage = event => { const data = JSON.parse(event.data); console.log(data); diff --git a/kinode/packages/settings/settings/src/lib.rs b/kinode/packages/settings/settings/src/lib.rs index 805d7a7d..f81661fe 100644 --- a/kinode/packages/settings/settings/src/lib.rs +++ b/kinode/packages/settings/settings/src/lib.rs @@ -249,6 +249,7 @@ fn handle_http_request( state: &mut SettingsState, http_request: &http::IncomingHttpRequest, ) -> anyhow::Result<()> { + state.fetch()?; match http_request.method()?.as_str() { "GET" => Ok(http::send_response( http::StatusCode::OK,