Tauri App with Embedded Actix Web Server – Localhost Not Reachable After Build #13551
Unanswered
Alirezaaraby
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Did you try a debug build via the |
Beta Was this translation helpful? Give feedback.
1 reply
-
I change lib.rs in tauri2, it works for me // lib.rs
use std::thread;
use actix_web::{web, App, HttpServer, Responder};
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
thread::spawn(|| {
actix_web::rt::System::new().block_on(async {
start_actix_server().await;
})
});
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
async fn start_actix_server() {
async fn hello() -> impl Responder {
"Hello from Actix"
}
HttpServer::new(|| App::new().route("/", web::get().to(hello)))
.bind(("127.0.0.1", 8080))
.unwrap()
.run()
.await
.unwrap();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’m developing a Tauri application that includes a built-in Actix Web server. Everything works perfectly during development when I run the app using npm run tauri dev. However, after building the application, the Actix server no longer responds to requests — it seems like localhost is not reachable.
I suspect this might be related to permissions or security restrictions in the production build, but I'm not entirely sure. I've already configured the connect-src directive in the Content Security Policy and attempted to bind the server to 0.0.0.0, but the issue persists.
Has anyone encountered a similar problem or have suggestions on what might be causing this?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions