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.07k stars 2.49k forks source link

Not allowed to load local resource #8917

Closed songjiachao closed 7 months ago

songjiachao commented 7 months ago

Describe the bug

image

I want to read image from homeDIr(file:///Users/11091628/.funapp/appIcons/Fun.app.png)

it return error "Not allowed to load local resource: file:///Users/11091628/.funapp/appIcons/Fun.app.png"

I have set fs config in capabilities

image

{ "identifier": "fs:allow-read", "allow": [{ "path": "$HOME/**" }] },

or { "identifier": "fs:scope", "allow": [{ "path": "$HOME/**" }] },

Both doesn't work

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.2.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.9.0
    - pnpm: 8.15.3
    - yarn: 1.22.19
    - npm: 10.1.0

[-] Packages
    - tauri [RUST]: 2.0.0-beta.2
    - tauri-build [RUST]: no manifest (2.0.0-beta.1, 2.0.0-beta.1)
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.25.0
    - tauri-cli [RUST]: 2.0.0-beta.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.0
    - @tauri-apps/cli [NPM]: 2.0.0-beta.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://127.0.0.1:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

amrbashir commented 7 months ago

file:// protocol is not supported, instead you need to use convertFileSrc from @tauri-apps/api NPM package and you need to configure app > security > asset_protocol in tauri.conf.json