fetch request file://xxxxx

370 views
Skip to first unread message

Benja Van

unread,
Oct 18, 2022, 4:29:49 AM10/18/22
to Chromium Extensions
I am developing an extension program for markdown reader, which is being transferred to V3 version recently. Since the manifest of V3 version does not support XMLHttpRequest API, I can only use fetch API. However, fetch cannot request the local file address of the file:// protocol, so I cannot realize the function of automatically requesting the changes of local files in the extension program and rendering markdown in real time. Do you have any good technical suggestions? 

Stefan Van Damme

unread,
Oct 18, 2022, 6:44:50 AM10/18/22
to Chromium Extensions, 8503...@qq.com
Hi there,

The File System Access API can read the content of your file. See this helpful resource:

Thanks,
Stefan vd

wOxxOm

unread,
Oct 18, 2022, 10:07:51 AM10/18/22
to Chromium Extensions, stefa...@gmail.com, 8503...@qq.com
`fetch` can access file:// scheme since Chrome 99.

Moe Bazzi

unread,
Oct 18, 2022, 11:59:00 AM10/18/22
to wOxxOm, Chromium Extensions, stefa...@gmail.com, 8503...@qq.com
fetch does with with file:// url schemes but you also need to have the 'file://' host permission set in your manifest and also the user has to manually go to your extensions detail page and check the 'Allow access to file urls' toggle (see screenshot) 

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/886b1159-8e81-4589-8d3a-411acfc17975n%40chromium.org.
Screenshot 2022-10-18 at 11.55.32 AM.png

Jackie Han

unread,
Oct 18, 2022, 4:32:15 PM10/18/22
to Moe Bazzi, wOxxOm, Chromium Extensions, stefa...@gmail.com, 8503...@qq.com
// in manifest.json
  "host_permissions": [
    "file://*/*"
  ],


In extension details
Screen Shot 2022-10-19 at 04.25.57.png

In my test, load unpacked extension with file:// permission, chrome allow above toggle automatically.


Moe Bazzi

unread,
Oct 18, 2022, 4:35:11 PM10/18/22
to Jackie Han, wOxxOm, Chromium Extensions, stefa...@gmail.com, 8503...@qq.com
Jackie, are you sure that chrome had the 'Allow access to file URLs' toggle on automatically? If so, this is huge. I wonder if this works for extensions downloaded from the store. Also, was this MV2 or MV3?

Jackie Han

unread,
Oct 18, 2022, 4:42:02 PM10/18/22
to Moe Bazzi, wOxxOm, Chromium Extensions, stefa...@gmail.com, 8503...@qq.com
Yes, it is MV3. I only tested from my local unpacked extension, I don't know CWS.

wOxxOm

unread,
Oct 19, 2022, 3:45:53 AM10/19/22
to Chromium Extensions, Jackie Han, wOxxOm, Chromium Extensions, stefa...@gmail.com, 8503...@qq.com, bazz...@gmail.com
It is enabled by default only for unpacked extensions.

Rxtester Beijing

unread,
Oct 20, 2022, 1:59:11 PM10/20/22
to Chromium Extensions, wOxxOm

Hi wOxxOm,
Do you have any suggestion about the issue: https://groups.google.com/a/chromium.org/g/chromium-extensions/c/ybJCN4YX_uU
Reply all
Reply to author
Forward
0 new messages