简体   繁体   中英

Tauri Not allowed to load local resource

I've been using electron for GUI interface development, recently I came across Tauri as electron alternative and coming to realize that the same code works on electron but not Tauri where:

<video controls preload src="file:\\C:\Users\User\Desktop\HelloTest\testVideo.mp4" ></video>

I've already tried:

<video controls preload src="C:\Users\User\Desktop\HelloTest\testVideo.mp4" ></video>

and the error is still Not allowed to load local resource: file:///.....

it works in electron by disabling the webSecurity:false in webPreference , is there any ways I can disable web security in Tauri, so that I can use local resources (videos from C:// or D://) in Tauri, my Tauri are using Angular as frontend

You can configure the security. Take a look at the documentation here: https://tauri.app/v1/api/js/modules/fs#security

  {
   "tauri": {
     "allowlist": {
       "fs": {
        "scope": ["$APP/databases/*"]
    }
  }

.Paths accessed with this API must be relative to one of the base directories so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM