#"Not allowed to load local resource"

78 messages Β· Page 1 of 1 (latest)

elder girder
#

I am trying to display / render an image using <img/>. The image is located in the system cache folder (appCacheFolder() from Tauri API). However it is failing due to "Not allowed to load local resource" error.

I've seen several similar errors after googling, but they all came from all sorts of frameworks and toolkit, and has their own way of workaround. What is Tauri's way to work around this?

Vanilla / No framework
TypeScript
Rust

#

Here's my allowlist:

"allowlist": {
      "all": false,
      "shell": {
        "all": false,
        "open": true
      },
      "protocol": {
        "assetScope": [
          "allow"
        ]
      },
      "path": {
        "all": true
      }
    },
#

the image does exist in the file system

lavish wing
#

okay i think moving the github discussion to here makes it a bit quicker (we can share the summary there at the end)

#

2 things:

  1. the url posted on github looks correct
  2. The scope you posted here is wrong. assetScope expects paths you want to allow.
#

so in this case "$APPCACHE/*" to allow all files (not recursively) in the appCacheDir

elder girder
#

whaaaa you sniffed all the way from github to here πŸ’€

elder girder
lavish wing
#

you can change it to "$APPCACHE/image/*" or "$APPCACHE/**" if you want to allow everything in that folder including subdirs

elder girder
#

I see, will try rn

#

mhm it seems that the issue persists πŸ€”

#

Ive noticed that this asset link is not working on its own in a regular browser

#

It's hard to tell if the link is actually "unsupported" or is it just invalid

#

though I don't see a problem with the currnet url being supplied

#

Ive had asset scope set up correctly (i assume) too

"protocol": {
  "assetScope": [
    "$APPCACHE/**",
    "$APPCACHE/cn.adam.pivix/**",
    "$APPCACHE/images/*"
  ]
},
lavish wing
elder girder
#

ah so its not meant to work directly in a browser

lavish wing
#

nope

elder girder
#

well in that case πŸ€” unsupported still tho

#

what could be the issue here

lavish wing
#

no idea, i can't remember seeing that issue before. 2 things to try though

  1. Try fetching the url instead of using it as an img src. often gives better errors
  2. try a different dir than appcachedir
elder girder
#

hm Ive used appDataDir, same outcome

#

for the first..do you mean use the fetch function in js?

lavish wing
#

yea

elder girder
# lavish wing yea

was discussing with someone yesterday about this too they suggested js but interestingly get requests sent from js gets rejected but every other ways (browsers, rust, c# etc) works perfectly fine

#

as for the website's api

lavish wing
#

well if it cant be solved then the only way is to switch tatics
which i alr have one but not related to this post-
Moving back to here

elder girder
#

lmao i knew u gonna do this

lavish wing
#

so the thing is, there's something specific to your system i'm missing

elder girder
#

hm?

#

macos ventura

lavish wing
lavish wing
#

i'd lean towards saying it's just you

elder girder
#

ah

worthy nymph
#

could it be a csp issue?

elder girder
worthy nymph
elder girder
elder girder
#

that hasnt been brought up here

lavish wing
#

that's the assetScope config

#

and only that

elder girder
#

πŸ€”

#

do i have an option to just grant my app access to the entire file system

lavish wing
#

yeah **

#

but

elder girder
#

including the recovery disk of my macos installation

lavish wing
#

if it'd be the scope causing issues the error, at least on fetch, would say so

elder girder
lavish wing
#

yes

elder girder
#

my web request was executed successfully without errors πŸ€” using reqwest crate

lavish wing
#

reqwest shouldn't have access to the asset protocol tho

#

either way, you gotta do the request inside the webview to get the same sandbox limitations etc

#

and cors/csp whatever

elder girder
#

it doesnt, its just responsible for dumping the downloaded image into one of the newly created file in system cache folder

worthy nymph
lavish wing
#

omg

elder girder
lavish wing
#

i'm apparently blind

worthy nymph
elder girder
#

ye il test it out asap rn im not on my dev machine

#

wait huh so even with assetscope defined, as long as asset is not explicitely set to true, all other protocols will be ignored? πŸ€”

lavish wing
#

yep

elder girder
#

aaaaa

#

its workingggggg

#

thank u both for yall's support 😭

lavish wing
#

time to quit the working group kkushKEKW

elder girder
#

been carpet-searching through the entire internet

lavish wing
#

thanks for catching that @worthy nymph. I would have searched for hours lol

elder girder
#

aksed chatgpt in 5 different ways

elder girder
lavish wing
#

yeah, chatgpt doesn't know anything about tauri, its dataset is too old

elder girder
worthy nymph
#

Great πŸ™‚ happy that I was able to help!