wry
wry copied to clipboard
Unable to get response from custom protocol when using `with_html`
Describe the bug
fetch
can not resolve body
Steps To Reproduce
The minimum reproducible code is here: https://github.com/fzdwx/wry-demo
Expected behavior
console.log(res.body)
is not null
Screenshots
response have value, is hello
but fetch can not reslove
Platform and Versions (please complete the following information):
❯ cargo tauri info
Environment
› OS: Arch Linux Unknown X64
› Node.js: 19.6.0
› npm: 8.19.2
› pnpm: 7.18.0
› yarn: 1.22.19
› rustup: 1.25.1
› rustc: 1.69.0-nightly
› cargo: 1.69.0-nightly
› Rust toolchain: nightly-x86_64-unknown-linux-gnu
Would you want to assign yourself to resolve this bug?
- [ ] Yes
- [x] No
Additional context
mybe https://bugs.webkit.org/show_bug.cgi?id=229034 ?
What's webkitgtk version from your devices?
Edit: I believe your sample also doesn't work. Could you give more context about it? It would be best it's a wry example that I can test directly.
What's webkitgtk version from your devices?
Edit: I believe your sample also doesn't work. Could you give more context about it? It would be best it's a wry example that I can test directly.
From my project https://github.com/fzdwx/popup-translation, and the webkitgtk version i will take you tomorrow.
@fzdwx I'm really glad it's a wry project already. But I couldn't find a way to open devtool and run a fetch command. What are the steps to do it?
Sorry, my bed. Append args -p google hello
And click button on the page
Hello, my webkitgkt version is :
❯ yay -Q webkit2gtk
webkit2gtk 2.38.4-1
I upgrade to 2.38.5-1
, it dont's work yet
The minimum reproducible code is here: https://github.com/fzdwx/wry-demo
I find use with_url
, fetch
response body is not null ! @wusyong
@fzdwx Thanks for the example again! Sorry I'm during vacation right now but I can tell you with_html
on Linux doesn't really behave like http://
origin. It has many caveats which tauri doesn't really use it. It's recommended to just use custom protocol URL scheme and call with_url
.
Thanks you for your reply ! But with_url
only load once on window create, i want to send my request to my rust application.
If you need my help later, please call me anytime.
From your use case (popup-translation), it looks like you already created the webview window and made it invisible from the start. Maybe you can create a webview window with with_url("wry://dev/google")
anyway? It shouldn't be a problem, even if it's an empty webpage.
@wusyong Thanks ! But I have to think about how to change my code .
Okay I think the cause is we set the origin to http://localhost
.
https://github.com/tauri-apps/wry/blob/dev/src/webview/webkitgtk/mod.rs#L366
We can expose an option to set it, but this will only work on macOS and Linux I'm afraid.
Has anyone managed to address this? I'm stuck here