Blueprint, access to a local plugin file

Hello,

I made a plugin that includes a blueprint with a select field that get options from a json file saved in the media folder. It was working very well until the hosting changed security settings and now I can’t use anymore the query url: "{{ site.url }}/media/plugins/msnlnz/cart/countries.js" as it’s blocked for security reasons and have to access to the file with a local path. I tried to replace {{ site.url }} with {{ root.site }} but it doesn’t work. I can I access to that folder via blueprint?
Thanks!

This was the blueprint field:

          country:
            type: select
            width: 1/3
            options: api
            api:
              url: "{{ site.url }}/media/plugins/XXX/cart/countries.js"
              text: "{{ item.country }}"
              value: "{{ item.abbreviation }}"

What sort of security reasons?

Basically they blocked this kind of requests. Also, my plugin was using file_get_contents to get the json file stored in the media folder, but as it was using a global link via the $site->url() object, was blocked by the server throwing a 403 error. I had to rewrite the plugin using local paths with the $kirby->root('media') but it doesn’t work on blueprint…

Don’t know if it’s relevant, but why are you trying to load a .js file (instead of .json)

Don’t know why :slight_smile: But does it solve the problem?

I don’t know, test it! But if you have json data, it should be in json file.

Make sense, thanks! But I tried it, same problem with the js file. 90% of the times the server block the loading of the file…

I think the only solution is to use a local path. If {{ site.url }} generates and http url, what can I use instead to get the local path to the media folder? Thanks

Still wondering what exactly they are blocking in the name of security? All calls to a URL instead of a path? What if you use a route that in turns gets the data from the path?

I don’t know exactly, and I’m quite desperate because I’m using that hosting for most of my websites but that’s another problem. Recently I found that is creating the same problem also with the library of mPDF I use on this kirby website Bulletta — ZAA. If you click on the bottom right button and generate the pdf, most of the times the images are missing, and that’s again that 403 error. They replied that “that kind of URL calls were creating issues of stability because are often used to create infinity loops…”

Do you have an example of that route?

Thanks!