Skip to content

Remove spurious AppSubUrl in serviceworker request. #16047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions web_src/js/features/serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {joinPaths} from '../utils.js';

const {UseServiceWorker, AppSubUrl, AssetUrlPrefix, AppVer} = window.config;
const {UseServiceWorker, AssetUrlPrefix, AppVer} = window.config;
const cachePrefix = 'static-cache-v'; // actual version is set in the service worker script
const workerAssetPath = joinPaths(AssetUrlPrefix, 'serviceworker.js');

Expand Down Expand Up @@ -41,10 +41,9 @@ export default async function initServiceWorker() {
// unregister all service workers where scriptURL does not match the current one
await unregisterOtherWorkers();
try {
// normally we'd serve the service worker as a static asset from AssetUrlPrefix but
// the spec strictly requires it to be same-origin so it has to be AppSubUrl to work
// the spec strictly requires it to be same-origin so the AssetUrlPrefix should contain AppSubUrl
await checkCacheValidity();
await navigator.serviceWorker.register(joinPaths(AppSubUrl, workerAssetPath));
await navigator.serviceWorker.register(workerAssetPath);
} catch (err) {
console.error(err);
await invalidateCache();
Expand Down