#Can't visit my server through trunk proxy

1 messages · Page 1 of 1 (latest)

finite shard
#

my trunk.toml below
[[proxy]]
rewrite = "/api/"
backend = "http://localhost:8080/"

my server setting:
.service(
web::scope("/blog")
.route("/{id}", web::get().to(get_blog))
)
.bind(("localhost", 8080))?
.workers(2)
.run()
.await
my request in yew:
wasm_bindgen_futures::spawn_local(async move {
let blog: BlogPost = Request::get(format!("/api/blog/{}", id).as_str()).mode(gloo_net::http::RequestMode::NoCors).send().await.unwrap().json().await.unwrap();
})

the trunk print:
2023-10-20T13:33:54.492068Z INFO success
2023-10-20T13:33:56.839970Z ERROR response failed classification=Status code: 502 Bad Gateway latency=2015 ms

i'm sure that my server is ok. and there is a weird thing: 'trunk serve --proxy-backend=https://yew.rs/tutorial/ --proxy-rewrite=/tutorial/' this is ok.....😭

nova lynx
#

front looks correct, i have no idea how to work with your backend, also try ensuring that you have no firewalls that may block anything

#

you might not need NoCors bit since both requests are to frontend since you are proxying

finite shard
#

the server can return data normally in vue. 😫

finite shard
#

this's the vite configuration, it works well

nova lynx
#

my trunk.toml and request url look the same so i guess its some problem on OS level

#

like its literally the same

finite shard
#

😭😭😭really sad, rust is too hard to make me think that i can't learn it well😆😆😆

nova lynx
#

rust has nothing to do with this i dont think lol

finite shard
nova lynx
#

it might seem harder than js/ts and python, but... the moment you start writing bigger projects you notice your code turn into an unfixable mess, where with rust you are forced to write an understandable structure. rust does all the things related to typing you have to just hold in your mind - what fields, methods do objects have, what things can you input into a function and what you get out, nulls
it might seem harder than c or c++, but... the moment you learn rust you realise that rust does all the things related to memory management that you have to just hold in your mind - lifetimes, mutability exclusivity, nulls, use after free