Repository: tauri
Issue: [bug] Inconsistent `register_uri_scheme_protocol` behaviour on Windows. Connection refused for requests from iframe.
Labels: type: bug,platform: Windows,status: needs triage

### 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

```tsx
import { convertFileSrc } from "@tauri-apps/api/core";
const iframeSrc = convertFileSrc("", "ext");
<iframe src={iframeSrc} title="iframe"></iframe>
```

This will try to load `index.html` with url 
- `ext://localhost/` on Mac
- `http://ext.localhost/` on Windows

The `index.html` loads a `main.js` and a `style.css`.
iframe automatically sends requests to fetch the 2 files 
- ` http://ext.localhost/main.js`
- ` http://ext.localhost/style.css`

`style.css` sets text color to red. `main.js` changes text from `External JavaScript File Not Loaded` to `External JavaScript Loaded`.

## Expected Behavior

On Mac, everything works perfectly

![image](https://github.com/user-attachments/assets/83bc93cd-310b-4d68-8974-533ecd9813b5)

## Problem

On Windows, only `index.html` is loaded. `style.css` and `main.js` fail to load.

![image](https://github.com/user-attachments/assets/f9c2b522-43bd-43c7-bc7b-c66070fc5853)

In the console, there are 2 errors
![image](https://github.com/user-attachments/assets/1a301f8f-0f31-4c66-8398-2c84748bfb16)

The requests to fetch `style.css` and `main.js` got connection refused. 
![image](https://github.com/user-attachments/assets/3e5d796a-00fc-4944-89bb-a50b596c92d7)

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

![image](https://github.com/user-attachments/assets/755d3d56-a8c6-4ec3-a9cb-24214f789381)
![image](https://github.com/user-attachments/assets/216ce823-efb8-4597-b7dd-62d296a8d81c)

### What a successful request look like

![image](https://github.com/user-attachments/assets/6d839e8d-6691-4b9d-aa0b-45ebfef0fc29)
![image](https://github.com/user-attachments/assets/c6742cf9-29a5-4165-9e20-e6110db56d84)

## 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.

```js
fetch("http://ext.localhost/main.js")
      .then((res) => res.text())
      .then((text) => {
        console.log(text);
      });
```

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 for `style.css` or `main.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, 

```ps
pnpm install
pnpm tauri dev
```


> [!CAUTION]
> Error only happens on Windows. It should work on Mac.

### Expected behavior

_No response_

### Full `tauri info` output

```text
[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 129.0.2792.89
    ✔ MSVC: 
        - Visual Studio Build Tools 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.17.0
    - pnpm: 9.9.0
    - npm: 10.8.2
    - bun: 1.1.33
    - deno: deno 2.0.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.3
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
```


### Stack trace

_No response_

### Additional context

This is very critical to my app, please help!

Thanks!