electron: registerURLSchemeAsPrivileged does not allow service worker to use file:// scheme
- Electron version: 1.6.10 ia32
- Operating system: windows 7 x64
Expected behavior
create-react-app comes with a service worker by default that uses the fetch API to cache and load resources. I’m expecting webFrame.registerURLSchemeAsPrivileged('file'); to allow the fetch to load with the file scheme.
Actual behavior
When fetch is used inside of Electron from the service worker the original error is:
Fetch API cannot load file://.... URL scheme "file" is not supported"
According to, https://github.com/electron/electron/issues/2831 https://github.com/electron/electron/issues/9474
“You can add fetch support to file scheme in your app by using webFrame.registerURLSchemeAsPrivileged api.”
So I attempted webFrame.registerURLSchemeAsPrivileged('file');
Which changes the error to:
Uncaught (in promise) TypeError: Request scheme 'file' is unsupported at service-worker.js:1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 15
- Comments: 27 (5 by maintainers)
Commits related to this issue
- Fix: Register File URL Scheme as Priviledged Adding `webFrame.registerURLSchemeAsPrivileged('file');` to the Electron render process is the sanctioned solution to fix `Fetch API cannot load... URL sc... — committed to nCoda/julius by siennamw 7 years ago
- Fix: Register File URL Scheme as Priviledged Adding `webFrame.registerURLSchemeAsPrivileged('file');` to the Electron render process is the sanctioned solution to fix `Fetch API cannot load... URL sc... — committed to nCoda/julius by siennamw 7 years ago
- Deregistering serviceWorkers - https://github.com/electron/electron/issues/9705 — committed to zenjara/myExpenses by korac 6 years ago
+1 electron v7.1.14
This issue persists in the latest electron versions. Other important Service Worker APIs appear to have not worked for years, too, such as Background Sync.
Electron: 2.0.0 Windows 10 64-bits Pro @codebytere @deepak1556 Could the
blockedlabel be removed? There’s a reproducible git repo up here in the commentsElectron: 2.0.5 Windows 10 Pro
After spending all evening looking at around posts, trying as many different hacky things as I can, I’ve come to realise that I’m suffering from the same problem in #13740 as is reported in here - the CRA service worker uses fetch(), which is throwing up the error mentioned at the beginning of this issue:
Uncaught (in promise) TypeError: Request scheme 'file' is unsupported at service-worker.js:1I am unsure if it’s possible to run the latest React without the service workers, but I’m guessing this issue will affect all React applications trying to run in Electron @codebytere ?
Any updates on this one? @pfrazee has a reproducible test case:
from https://github.com/electron/electron/issues/9663
So can we remove the
blockedtag on this issue?@codebytere I just checked my test case for https://github.com/electron/electron/issues/9663 and it’s still failing
+1
electron: 1.7.8 mac: macOS Sierra 10.12.6
+1
same for: