Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CORS headers #6

Open
insipx opened this issue Dec 11, 2024 · 0 comments
Open

Setup CORS headers #6

insipx opened this issue Dec 11, 2024 · 0 comments

Comments

@insipx
Copy link

insipx commented Dec 11, 2024

CORS headers need to be setup in order to allow WASM requests to go through from the browser. Can try using fetch_mode_no_cors, but the browser itself disallows that request and results in it failing:

ERROR xmtp_mls/src/groups/device_sync.rs:344 sync worker error reqwest error: error sending request inbox_id = "0e773081fe1824c35f9306d414c8c278eed43f57bfe5441119e6a0440d052cee";installation_id = "2054bbe5d616f9aff8ffb9643ac6d9d224711be223f2df408391a8ee97dcef35";

on further investigation this is revealed to be a fetch error:

JsValue(TypeError: Failed to fetchTypeError: Failed to fetch    at http://localhost:8000/wasm-bindgen-test:947:21    at logError (http://localhost:8000/wasm-bindgen-test:17:18)    at imports.wbg.__wbg_fetch_b335d17f45a8b5a1 (http://localhost:8000/wasm-bindgen-test:946:68)    at xmtp_mls-338b2af48685e0b2.wasm.__wbg_fetch_b335d17f45a8b5a1 externref shim (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[16156]:0x61106d)    at xmtp_mls-338b2af48685e0b2.wasm.reqwest::wasm::client::js_fetch::he87d96ccfb1eabe7 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[6332]:0x51a499)    at xmtp_mls-338b2af48685e0b2.wasm.reqwest::wasm::request::RequestBuilder::send::{{closure}}::h3bcd09dd934bfa91 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[412]:0x1a062c)    at xmtp_mls-338b2af48685e0b2.wasm.xmtp_mls::groups::device_sync::SyncWorker<ApiClient,V>::on_request::{{closure}}::h36e4e08bd3478bb8 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[218]:0x4b3a2)    at xmtp_mls-338b2af48685e0b2.wasm.xmtp_mls::groups::device_sync::SyncWorker<ApiClient,V>::run::{{closure}}::hcf66a7f257dfdc9a (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[209]:0x210fe)    at xmtp_mls-338b2af48685e0b2.wasm.futures_util::future::future::FutureExt::poll_unpin::h585df9976ee641df (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[409]:0x19d0a7)    at xmtp_mls-338b2af48685e0b2.wasm.<futures_util::future::select::Select<A,B> as core::future::future::Future>::poll::h911884014f79df2e (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[8587]:0x57a28a))

fetch_mode_no_cors fundamentally changes the browser response into something different, which reqwest may not expect. Article on topic: https://tpiros.dev/blog/what-is-an-opaque-response/

possibly related: seanmonstar/reqwest#1401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant