I am trying to get the custom protocol of wry to work on Linux but webkit always throws me an access control allow origin error despite being enabled for all origins (*) just like the docs say
I used as reference the wry /examples, tauri internals and tauri-bindgen's ipc-router-wip
Am I missing something? 🤔
use std::borrow::Cow;
use wry::{
application::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
},
http::{header::ACCESS_CONTROL_ALLOW_ORIGIN, HeaderValue, Response, StatusCode},
webview::WebViewBuilder,
};
fn main() {
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title("Hello World")
.build(&event_loop)
.unwrap();
let _webview = WebViewBuilder::new(window)
.unwrap()
.with_custom_protocol("hello".into(), move |_request| {
let resp = Response::builder()
.status(StatusCode::OK)
.header(ACCESS_CONTROL_ALLOW_ORIGIN, HeaderValue::from_static("*"))
.body(Cow::Owned("hi".as_bytes().to_vec()))
.map_err(Into::into);
println!("{resp:?}");
resp
})
.with_url("http://localhost:4507/")
.unwrap()
.build()
.unwrap();
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
_ => {}
},
_ => (),
}
});
}