tauri-apps / tauri

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

Failed to load resource: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. #4722

Open UvDream opened 2 years ago

UvDream commented 2 years ago

Describe the bug

Are HTTP resource requests not allowed?I am an application packaged by macos and found that http images cannot be loaded using,And I configured http

"tauri": {
    "allowlist": {
      "all": true,
      "http": {
        "all": true,
        "request": true
      }
    },

or

"tauri": {
    "allowlist": {
      "all": true,
      "http": {
        "all": true,
        "request": true,
        "scope":["www.xxxx.com/*"]
      }
    },

No effect, any resources of http are not allowed to be requested

image

Reproduction

No response

Expected behavior

Hope that the packaged http image can be used

Platform and versions

Environment
  › OS: Mac OS 12.4.0 X64
  › Node.js: 16.13.0
  › npm: 8.1.0
  › pnpm: 6.32.4
  › yarn: 1.22.18
  › rustup: 1.24.3
  › rustc: 1.60.0-nightly
  › cargo: 1.60.0-nightly
  › Rust toolchain: nightly-aarch64-apple-darwin

Packages
  › @tauri-apps/cli [NPM]: 1.0.4
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.4,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/
  › framework: React

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ src-tauri
  ├─ .git
  ├─ .idea
  └─ src

Stack trace

No response

Additional context

No response

absidue commented 2 years ago

By default macOS doesn't allow apps to communicate over unsecured HTTP, so you have to specifically tell it to allow you app to do so. Please see the the guide for bundling apps for macOS, specifically the part about the exception domain: https://tauri.app/v1/guides/building/macos#application-bundle-customization