tauri-apps / tauri

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

[bug] 403 in tauri v2 where I used `convertFileSrc` #9648

Closed kingzcheung closed 1 week ago

kingzcheung commented 2 weeks ago

Describe the bug

const selected = await open({
        multiple: false,
        directory: true,
    });

let entities = await readDir(selected) //... // for entities let filepath = await join(selected,entity.name) let src = convertFileSrc(filepath)

asset path src got

Failed to load resource: the server responded with a status of 403 (Forbidden)

Reproduction

No response

Expected behavior

No response

Full tauri info output

Environment
    - OS: Ubuntu 22.04 X64
    ✔ webkit2gtk-4.1: 2.44.0
    ✔ rsvg2: 2.52.5
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 21.7.3
    - pnpm: 9.0.6
    - npm: 10.5.0

[-] Packages
    - tauri [RUST]: 2.0.0-beta.17
    - tauri-build [RUST]: 2.0.0-beta.13
    - wry [RUST]: 0.39.3
    - tao [RUST]: 0.27.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.11
    - @tauri-apps/cli [NPM]: 2.0.0-beta.15

[-] App
    - build-type: bundle
    - CSP: default-src 'self' customprotocol: asset:; connect-src ipc: http://ipc.localhost; font-src https://fonts.gstatic.com; img-src 'self' asset: http://asset.localhost blob: data:; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 2 weeks ago

Did you configure the scope in tauri.conf.json? (the asset protocol is the only thing still using the scope instead of the new ACL) https://github.com/tauri-apps/tauri/blob/dev/examples/api/src-tauri/tauri.conf.json#L30-L36

FabianLars commented 2 weeks ago

Ah nvm, i somehow skipped over the mention of the dialog use, disregard the scope setting, but you may still have to use enabled: true 🤔

kingzcheung commented 1 week ago

Did you configure the scope in tauri.conf.json? (the asset protocol is the only thing still using the scope instead of the new ACL) https://github.com/tauri-apps/tauri/blob/dev/examples/api/src-tauri/tauri.conf.json#L30-L36

I had set it up, but it cannot solve this issue

FabianLars commented 1 week ago

Would it be possible to create a minimal reproduction repo we can check out?

If not, please share the capability file(s) in src-tauri/capabilities/ for a start.

kingzcheung commented 1 week ago

Sorry, I had abandoned the tauri v2