gloo icon indicating copy to clipboard operation
gloo copied to clipboard

Gloo-net Missing custom headers when sending post request.

Open ITUserG01 opened this issue 2 years ago • 2 comments

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.

wasm

Additional Context

Thank you for the help! It is much appreciated.

ITUserG01 avatar Nov 02 '22 16:11 ITUserG01

~I seem to be having the same issue~

Dyhr avatar Jan 23 '23 14:01 Dyhr

@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.

Dyhr avatar Jan 25 '23 09:01 Dyhr