hotfix: settings page work on secure connections

This commit is contained in:
dr-frmr 2024-05-08 15:35:38 -06:00
parent da036ea6af
commit 4637b1f500
No known key found for this signature in database
2 changed files with 7 additions and 10 deletions

View File

@ -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);

View File

@ -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,