Skip to content

Commit 4637b1f

Browse files
committed
hotfix: settings page work on secure connections
1 parent da036ea commit 4637b1f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

kinode/packages/settings/pkg/ui/script.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ const APP_PATH = '/settings:settings:sys/ask';
22

33
// Fetch initial data and populate the UI
44
function init() {
5-
fetch('/our')
6-
.then(response => response.text())
5+
fetch(APP_PATH)
6+
.then(response => response.json())
77
.then(data => {
8-
const our = data + '@settings:settings:sys';
9-
fetch(APP_PATH)
10-
.then(response => response.json())
11-
.then(data => {
12-
console.log(data);
13-
populate(data);
14-
});
8+
console.log(data);
9+
populate(data);
1510
});
1611
}
1712

@@ -158,7 +153,8 @@ document.getElementById('ping-peer').addEventListener('submit', (e) => {
158153
})
159154

160155
// Setup WebSocket connection
161-
const ws = new WebSocket("ws://" + location.host + "/settings:settings:sys/");
156+
const wsProtocol = location.protocol === 'https:' ? 'wss://' : 'ws://';
157+
const ws = new WebSocket(wsProtocol + location.host + "/settings:settings:sys/");
162158
ws.onmessage = event => {
163159
const data = JSON.parse(event.data);
164160
console.log(data);

kinode/packages/settings/settings/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ fn handle_http_request(
249249
state: &mut SettingsState,
250250
http_request: &http::IncomingHttpRequest,
251251
) -> anyhow::Result<()> {
252+
state.fetch()?;
252253
match http_request.method()?.as_str() {
253254
"GET" => Ok(http::send_response(
254255
http::StatusCode::OK,

0 commit comments

Comments
 (0)