Open bahmutov opened 8 years ago
Relevant client.js code
function getCurrentScriptFolder () {
var scriptEls = document.getElementsByTagName('script')
var thisScriptEl = scriptEls[scriptEls.length - 1]
var scriptPath = thisScriptEl.src
return scriptPath.substr(0, scriptPath.lastIndexOf('/') + 1)
}
var serviceScriptUrl = getCurrentScriptFolder() + 'express-service.js'
var scope = '/'
root.navigator.serviceWorker.register(serviceScriptUrl, { scope: scope })
.then(registeredWorker)
.catch(onError)
While using service worker for my web app.I am caching a file named gadget.js file. But inside that file is inserting some script files like, doc =document.createElement('iframe'); doc.write(`<!DOCTYPE html>
`); doc.close(); when i am trying to load the app in offline mode the script file('xxx/xxx/abc.js') is not getting proxied by service-worker.Since it is not getting detected(proxied) by service-worker i am getting a 404 error. Please help to solve this.....
To be able to make the stand alone desktop application using nativefier
To build
Currently, HTML, CSS and client.js are cached inside the app and load, but the service worker script is not. Probably because it is loaded dynamically from the client.js. When starting the app in offline mode for the very first time it fails to load the service worker js. If it can load it the first time then it works in offline mode after that.