Open HuakunShen opened 1 day ago
Related issue and discusstion:
Seems like real custom protocol on Windows won't arrive in Tauri v2.
Tauri's custom protocol is implemented differently on Windows, it's not a real custom protocol.
I don't know how ext.localhost
is handled under the hood.
I am guessing, requests from regular webview window is sent to Tauri core, while requests from iframe doesn't know where http://ext.localhost/
is.
Requests from iframe should be somehow redirected to Tauri core.
Describe the bug
Note: The error only happens on Windows.
What I was trying to do
I was trying to load a static website from local file system into a tauri app using iframe (for a plugin system).
To achieve this, I implemented a custom protocol with
register_uri_scheme_protocol
. What I did was basically implementing a file server to serve static html, css, js files (so I don't need to spawn another http file server).How It Works
It works like this
This will try to load
index.html
with urlext://localhost/
on Machttp://ext.localhost/
on WindowsThe
index.html
loads amain.js
and astyle.css
. iframe automatically sends requests to fetch the 2 fileshttp://ext.localhost/main.js
http://ext.localhost/style.css
style.css
sets text color to red.main.js
changes text fromExternal JavaScript File Not Loaded
toExternal JavaScript Loaded
.Expected Behavior
On Mac, everything works perfectly
Problem
On Windows, only
index.html
is loaded.style.css
andmain.js
fail to load.In the console, there are 2 errors
The requests to fetch
style.css
andmain.js
got connection refused.The 2 requests timed out after 2 seconds, while the first request to
index.html
resolves in 1ms.Here are more info about the failed request
What a successful request look like
My Hypothesis
I thought there was something wrong with the implementation of the custom file server I implemented with Rust and
tauri::http
.However, fetching
main.js
from Tauri app works perfectly.And from the log message in my custom file server rust code, I can see that, there was only request to
index.html
, no request forstyle.css
ormain.js
at all.So tauri core basically denies the connection from iframe, but not from the window.
I don't know what the difference is between request from window and iframe, but this behavior is completely different from MacOS.
Reproduction
https://github.com/[HuakunShen/tauri-windows-uri-scheme-bug
To run it,
Expected behavior
No response
Full
tauri info
outputStack trace
No response
Additional context
This is very critical to my app, please help!
Thanks!