gloo
gloo copied to clipboard
Gloo-net Missing custom headers when sending post request.
Describe the Bug
While using yew gloo_net will not add in any custom user defined headers.
This is needed for calling surrealdb's REST API which requires custom headers: "NS" for namespace selection and "DB" for database selection.
A clear and concise description of what the bug is. Testing on Firefox V106.0.3 using yew V0.19.3
Steps to Reproduce
While inside an async function call Request::new()
let resquest = gloo_net::http::Request::new(&URL) .header("NS", "my_namespace") .header("DB", "my_namespace") .header("Accept", "application/json") .body(wasm_bindgen::JsValue::from_str("SELECT * FROM User")) .mode(RequestMode::NoCors) [.method(Method::POST)](url) .send() [.await;
]
If applicable, add a link to a test case (as a zip file or link to a repository we can clone).
Expected Behavior
Sends requested user defined headers inside from browser to DB.
Actual Behavior
Does not send user defined header from browser to DB.
Additional Context
Thank you for the help! It is much appreciated.
~I seem to be having the same issue~
@ITUserG01 it seemed to be a CORS issue for me. I was able to solve it by running my services through the same server, but configuring CORS correctly is probably the way to go.