Skip to content

Commit fd1bcca

Browse files
authored
fix(desktop): grant the localhost webview IPC access so the updater works (#57)
The window loads the whole app over HTTP (http://localhost:34115), which Tauri treats as remote content — and remote content gets no command access by default. So the updater's invoke() calls were silently denied and the toast never showed (the rest of the app talks to the server over HTTP, so the updater was the first thing to need IPC). Add a remote.urls grant for the local server to the capability. Also log the updater check in every build and stop swallowing the JS error, so an IPC/updater failure is diagnosable from a terminal instead of silent.
1 parent 99dacd8 commit fd1bcca

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

app/src-tauri/capabilities/default.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"$schema": "../gen/schemas/desktop-schema.json",
33
"identifier": "default",
4-
"description": "enables the default permissions",
4+
"description": "Default permissions, plus IPC access for the local server the window loads (http://localhost:34115). The shell serves the whole app over HTTP, so to Tauri its content is 'remote' and needs an explicit grant to call commands (e.g. the updater).",
55
"windows": ["main"],
6+
"remote": {
7+
"urls": ["http://localhost:34115", "http://localhost:34115/*"]
8+
},
69
"permissions": [
710
"core:default",
811
{

app/src-tauri/src/lib.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,19 @@ async fn updater_check(
124124
app: tauri::AppHandle,
125125
pending: tauri::State<'_, PendingUpdate>,
126126
) -> Result<Option<UpdateInfo>, String> {
127-
let update = app
128-
.updater()
129-
.map_err(|e| e.to_string())?
130-
.check()
131-
.await
132-
.map_err(|e| e.to_string())?;
127+
log::info!("updater_check: querying for updates");
128+
let updater = app.updater().map_err(|e| {
129+
log::error!("updater_check: updater unavailable: {e}");
130+
e.to_string()
131+
})?;
132+
let update = updater.check().await.map_err(|e| {
133+
log::error!("updater_check: check failed: {e}");
134+
e.to_string()
135+
})?;
136+
match &update {
137+
Some(u) => log::info!("updater_check: update available: {}", u.version),
138+
None => log::info!("updater_check: up to date"),
139+
}
133140
let info = update.as_ref().map(|u| UpdateInfo {
134141
version: u.version.clone(),
135142
current_version: u.current_version.clone(),
@@ -205,13 +212,14 @@ pub fn run() {
205212
.manage(PendingUpdate(Mutex::new(None)))
206213
.invoke_handler(tauri::generate_handler![updater_check, updater_install])
207214
.setup(|app| {
208-
if cfg!(debug_assertions) {
209-
app.handle().plugin(
210-
tauri_plugin_log::Builder::default()
211-
.level(log::LevelFilter::Info)
212-
.build(),
213-
)?;
214-
}
215+
// Log in every build (stdout + the OS log dir), so the updater path — the
216+
// one place that uses Tauri IPC — can be diagnosed from a terminal even on
217+
// a release, where the webview console isn't available.
218+
app.handle().plugin(
219+
tauri_plugin_log::Builder::default()
220+
.level(log::LevelFilter::Info)
221+
.build(),
222+
)?;
215223

216224
// Bundled build: start the server via the vendored node sidecar. The data
217225
// dir is the per-OS app-data dir; migrations + mod source are bundled

app/src/components/update-prompt.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function UpdatePrompt() {
4444
checked.current = true;
4545
checkForUpdate()
4646
.then((u) => u && setUpdate(u))
47-
.catch(() => {});
47+
.catch((err) => console.error("[updater] check failed", err));
4848
}, []);
4949

5050
if (!update) return null;

0 commit comments

Comments
 (0)