Why does the pc terminal run well but not on the mobile phone? #2538
Replies: 2 comments 2 replies
-
I don't understand what you're asking, sorry. |
Beta Was this translation helpful? Give feedback.
-
It's a little hard to answer a question like this since you haven't described what you are expecting, what you are actually experiencing, and what you've tried to do to resolve the issue. However, I can make a guess. Your application is trying to access "127.0.0.1:5000", which is a network port 5000 on the local device. I would imagine that it works on your computer because you have something running that is listening and operating on port 5000, and responding to the "/login1" HTTP request. However, that likely isn't the case on your phone. The way you created this, it will always access "this device". |
Beta Was this translation helpful? Give feedback.
-
i have the following code:
use leptos::*;
use leptos_router::use_navigate;
use serde_json::json;
use gloo_net::http::Request;
use gloo_storage::{LocalStorage, Storage};
use gloo_storage::SessionStorage;
use leptos::html::{Form,A};
#[component]
pub fn Login() -> impl IntoView {
let navigation=use_navigate();
let (username,set_username)=create_signal("".to_string());
let (password,set_password)=create_signal("".to_string());
let on_click=move |ev:ev::MouseEvent| {
ev.prevent_default();
let navigation=navigation.clone();
spawn_local(async move {
let username=username.get();
let password=password.get();
let json_data=json!({
"username":username,
"password":password,
});
let form_data=json_data.to_string();
let res=Request::post("http://127.0.0.1:5000/login1")
.header("Content-Type","application/json")
.body(form_data)
.unwrap()
.send()
.await
.unwrap();
if res.status() == 200 {
let token=res.text().await.unwrap();
SessionStorage::set("Authorization", token).unwrap();
navigation("/home",Default::default());
} else {
navigation("/login",Default::default());
}
}
Beta Was this translation helpful? Give feedback.
All reactions