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

Most upvoted comments

+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 blocked label be removed? There’s a reproducible git repo up here in the comments

Electron: 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:1

I 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:

git clone https://github.com/pfrazee/electron-bug-service-workers-failure
cd electron-bug-service-workers-failure
npm i
npm start

from https://github.com/electron/electron/issues/9663

So can we remove the blocked tag 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:

  • Electron version: 1.6.8
  • Operating system: macox 10.11.6