Skip to content

Commit 81b853b

Browse files
authored
fix(core): Set json content type for errors returned from commands (#9213)
1 parent 75f5cb4 commit 81b853b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changes/fix-ipc-error-json.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri: 'patch:bug'
3+
---
4+
5+
Fixed an issue where errors where returned as strings instead of objects from commands.

core/tauri/src/ipc/protocol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn get<R: Runtime>(manager: Arc<AppManager<R>>, label: String) -> UriSchemeP
9292
let mut response =
9393
http::Response::new(serde_json::to_vec(&e.0).unwrap().into());
9494
*response.status_mut() = StatusCode::BAD_REQUEST;
95-
(response, mime::TEXT_PLAIN)
95+
(response, mime::APPLICATION_JSON)
9696
}
9797
};
9898

@@ -305,7 +305,7 @@ fn handle_ipc_message<R: Runtime>(message: String, manager: &AppManager<R>, labe
305305
mime_type = match &response {
306306
InvokeResponse::Ok(InvokeBody::Json(_)) => mime::APPLICATION_JSON,
307307
InvokeResponse::Ok(InvokeBody::Raw(_)) => mime::APPLICATION_OCTET_STREAM,
308-
InvokeResponse::Err(_) => mime::TEXT_PLAIN,
308+
InvokeResponse::Err(_) => mime::APPLICATION_JSON,
309309
}
310310
.essence_str()
311311
)

0 commit comments

Comments
 (0)