Skip to content

Commit

Permalink
hotfix: settings page work on secure connections
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-frmr committed May 8, 2024
1 parent da036ea commit 4637b1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
16 changes: 6 additions & 10 deletions kinode/packages/settings/pkg/ui/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions kinode/packages/settings/settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4637b1f

Please sign in to comment.