tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
83.65k stars 2.51k forks source link

Failed to load resource: net::ERR_CONNECTION_REFUSED #7114

Closed ezewu closed 1 year ago

ezewu commented 1 year ago

Describe the bug

Tauri opens the web project on the local hard disk. If the opened project introduces js, it will report an error, Failed to load resource: net::ERR_CONNECTION_REFUSED, how to solve this problem, thank you for your help, I searched for this in Issues The problem seems to be solved by using register_uri_scheme_protocol, but I’m not sure if it can be solved. I don’t know how to rust code, and I didn’t run the code snippets posted by others.

Reproduction

No response

Expected behavior

No response

Platform and versions

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 113.0.1774.57
    ✔ MSVC: Visual Studio Community 2019
    ✔ rustc: 1.69.0 (84c898d65 2023-04-16)
    ✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.1.0
    - pnpm: 8.4.0
    - npm: 9.6.4

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.3.0
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: default-src 'self'; img-src 'self' asset: https://asset.localhost
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 1 year ago

Could you create a reproduction example? I have difficulties following the steps you take to get the issue.

ezewu commented 1 year ago

Ok, I will write an example to upload to the warehouse, it may be next Monday, thank you

ezewu commented 1 year ago

@FabianLars https://github.com/ezewu/appiframe This is the code repository I use

  imageSrc.value = convertFileSrc("C:\\data\\1.png");
  iframeSrc.value = convertFileSrc("C:\\data\\1\\index.html");

When base.js is introduced into index.html, it will report an error

amrbashir commented 1 year ago

This is an upstream issue, see https://github.com/MicrosoftEdge/WebView2Feedback/issues/2341

You're basically using our built-in protocol asset but on Windows, iframe requests are not captured, it is a limitation in WebView2.

They added a new API to fix this shortcoming but we can't use it until it is stable.

ezewu commented 1 year ago

Thank you for your answer, how to use this new api AddWebResourceRequestedFilter in tauri

FabianLars commented 1 year ago

Like Amr said, it can't be used until it lands in a stable SDK, which did not happen yet.

ezewu commented 1 year ago

This function is currently completely useless, and it is still under development?

FabianLars commented 1 year ago

The new WebView2 api that will allow Tauri to also listen to requests inside iframes and not just in the main window is still under development, yes. In other words, we have to wait for Microsoft to be able to fix your issue.

ezewu commented 1 year ago

@FabianLars @amrbashir Thank you for the answer, it seems that I will use electron for a while

c0ncentus commented 8 months ago

[✔] Environment

[-] Packages

[-] App

I have same issue

Solve issue with this config

      "protocol": {
        "all": true,
        "asset": true,
        "assetScope": ["*"]
      },

would be appreciate some indication in the documentation ... #Rip_The_Doc.