Allow service workers to have the scope / which is needed for the interceptor

This commit is contained in:
Kegan Dougal 2020-02-25 15:27:31 +00:00
parent 349d3e3d47
commit 3fcc3c8bfd
3 changed files with 6 additions and 3 deletions

View File

@ -174,7 +174,7 @@ export async function loadApp() {
// load dendrite, if available // load dendrite, if available
if (window.vector_dendrite_worker_script && 'serviceWorker' in navigator) { if (window.vector_dendrite_worker_script && 'serviceWorker' in navigator) {
window.addEventListener('load', ()=>{ window.addEventListener('load', ()=>{
navigator.serviceWorker.register(window.vector_dendrite_worker_script).then(function(registration) { navigator.serviceWorker.register(window.vector_dendrite_worker_script, { scope: "/" }).then(function(registration) {
// Registration was successful // Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope) console.log('ServiceWorker registration successful with scope: ', registration.scope)
}, (err)=>{ }, (err)=>{

Binary file not shown.

View File

@ -35,9 +35,9 @@ module.exports = (env, argv) => {
"indexeddb_worker": "./src/vector/indexeddb-worker.js", "indexeddb_worker": "./src/vector/indexeddb-worker.js",
"dendrite_sw": "./src/vector/dendrite-sw.js", "dendrite_sw": "./src/vector/dendrite-sw.js",
"mobileguide": "./src/vector/mobile_guide/index.js", "mobileguide": "./src/vector/mobile_guide/index.js",
"sqlite_bridge": "./node_modules/go-sqlite3-js/js/bridge.js", "sqlite_bridge": "./node_modules/go-sqlite-js/js/bridge.js",
"go_http_bridge": "./node_modules/go-http-js-libp2p/js/bridge.js", "go_http_bridge": "./node_modules/go-http-js-libp2p/js/bridge.js",
"sql_wasm": "./node_modules/go-sqlite3-js/node_modules/sql.js/dist/sql-wasm.wasm", "sql_wasm": "./node_modules/sql.js/dist/sql-wasm.wasm",
"dendrite_wasm": "./src/vector/dendrite.wasm", "dendrite_wasm": "./src/vector/dendrite.wasm",
"wasm_exec": "./src/vector/wasm_exec.js", "wasm_exec": "./src/vector/wasm_exec.js",
@ -355,6 +355,9 @@ module.exports = (env, argv) => {
// don't fill the console up with a mahoosive list of modules // don't fill the console up with a mahoosive list of modules
chunks: false, chunks: false,
}, },
headers: {
"Service-Worker-Allowed": "/"
},
// hot module replacement doesn't work (I think we'd need react-hot-reload?) // hot module replacement doesn't work (I think we'd need react-hot-reload?)
// so webpack-dev-server reloads the page on every update which is quite // so webpack-dev-server reloads the page on every update which is quite