You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ServiceWorker does not allow 'file://' origin #2831
For this I was trying to use a service worker since they allow to intercept the network requests and modify the URL.
The problem is that electron (well chromium) does not allow "file://" origin. Chromium states that Service Workers require a secure origin, such as HTTPS.
The exact error is:
"Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported."
It seems as if many Chrome APIs are moving to HTTPS-only, it'd be great to have a single "registerURLSchemeAsPrivileged" method to encompass all of these features instead of having to one-off all of them
It seems as if many Chrome APIs are moving to HTTPS-only, it'd be great to have a single "registerURLSchemeAsPrivileged" method to encompass all of these features instead of having to one-off all of them
registerURLSchemeAsPrivileged sounds good, but should it allow file and like scheme or we can just allow custom schemes which are registered as standard ? Otherwise will file like schemes elevated as privileged lead to origin issues ?
Currently I receiving this error on the console, if I try to register a service worker from a filepath: error when registering sw DOMException: Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script.
I tried to register the file protocol at every method, but still no luck so far
Thanks for your response and the test case. I'm using Electron 0.36.1, so the file protocol should be supported for service workers.
I reduced the problem to the simple registration of an service worker and it still fails on my machine, even though it is fully covered by your test case. sw.js exists under this path (when i copy the path from the error to a browser instance the file is loaded). However this is not relevant for the error, it does not change if I remove the worker file.
On the console I receive an error, that the registration failed. The network monitor shows a strange error, I guess the browser must have somehow blocked the request.
Any idea what could be different about my environment, that causes this behaviour?
The problem for me was caused by electron-compile, which still suffers by that issue. I'm now using gulp for build an service workers work like a charm now.
Hey, I am able to make a Fetch request but unable to save the response in the Caches API's cache I have to create an cached app read from an in memory webui.zip file
Is this even possible?
I get the error that file:// request is unsupported by the cache api
Reacted by Ambroise Rabier, Weston Wedding, Johannes Millan, Jacob Ochs, Alexey Chudinov and Simon Siefke
Activity
zcbenz commentedon Sep 21, 2015
We can provide a
webFrame.registerURLSchemeAsAllowingServiceWorkersAPI for this.anaisbetts commentedon Sep 21, 2015
It seems as if many Chrome APIs are moving to HTTPS-only, it'd be great to have a single "registerURLSchemeAsPrivileged" method to encompass all of these features instead of having to one-off all of them
zcbenz commentedon Sep 21, 2015
👍
deepak1556 commentedon Sep 21, 2015
registerURLSchemeAsPrivilegedsounds good, but should it allowfileand like scheme or we can just allow custom schemes which are registered as standard ? Otherwise willfilelike schemes elevated as privileged lead to origin issues ?zcbenz commentedon Sep 21, 2015
@deepak1556 A simpe wrapper around blink APIs should be enough, we don't need to make the API do too much things unless it is proven that we have to.
PhilJ commentedon Dec 20, 2015
Any updates here?
Currently I receiving this error on the console, if I try to register a service worker from a
filepath:error when registering sw DOMException: Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script.I tried to register the file protocol at every method, but still no luck so far
Has anybody been able to successfully register a service worker via
file:///?deepak1556 commentedon Dec 20, 2015
@PhilJ 'file' scheme has been registered to enable service worker by default from v0.36.0 . which version of electron are you on ?
Have verified working with https://github.com/GoogleChrome/samples/tree/gh-pages/service-worker . Could you provide sample app in case it doesn't work for you, thanks!
PhilJ commentedon Dec 20, 2015
Thanks for your response and the test case. I'm using Electron 0.36.1, so the file protocol should be supported for service workers.
I reduced the problem to the simple registration of an service worker and it still fails on my machine, even though it is fully covered by your test case.
sw.jsexists under this path (when i copy the path from the error to a browser instance the file is loaded). However this is not relevant for the error, it does not change if I remove the worker file.On the console I receive an error, that the registration failed. The network monitor shows a strange error, I guess the browser must have somehow blocked the request.
Any idea what could be different about my environment, that causes this behaviour?
deepak1556 commentedon Dec 22, 2015
@PhilJ could you try clearing sw storage data using
session.clearStorageDataand retry.havenchyk commentedon Dec 23, 2015
@deepak1556 I also have this kind of problem with
0.36.0. Also reported issue #3897havenchyk commentedon Dec 23, 2015
@deepak1556 after
session.clearStorageDateI have the same message:havenchyk commentedon Dec 23, 2015
@PhilJ In my case the problem was in the old version of
electron-prebuiltPhilJ commentedon Feb 23, 2016
The problem for me was caused by
electron-compile, which still suffers by that issue. I'm now using gulp for build an service workers work like a charm now.anaisbetts commentedon Feb 24, 2016
Can you file a bug for this?
Testing allowing ServiceWorkers to be loaded from file protocol
VandeurenGlenn commentedon Jul 24, 2016
Maybe replacing request.url could be a solution (temporary)?
rahul-dutt-sharma commentedon Jan 23, 2018
Hey, I am able to make a Fetch request but unable to save the response in the
CachesAPI's cache I have to create an cached app read from an in memory webui.zip fileIs this even possible?
I get the error that file:// request is unsupported by the cache api