Changeset a3e0746 in Klonkt


Ignore:
Timestamp:
06/27/2026 09:02:29 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
ca0ad44
Parents:
cb95343
Message:

fix(sw): do not intercept cross-origin iframe navigations (PWA embeds)

  • server.js — the /sw.js fetch handler now skips cross-origin navigate requests, so YouTube/Spotify/SoundCloud embed iframes load natively in the installed PWA (which is always SW-controlled) instead of getting an opaque/blank response; bump CACHE_VERSION v15->v16 to roll the service worker.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/server.js

    rcb95343 ra3e0746  
    395395  res.set('Cache-Control', 'no-cache');
    396396  res.send(`
    397 const CACHE_VERSION = 'pcms-v15-' + new Date().toISOString().split('T')[0];
     397const CACHE_VERSION = 'pcms-v16-' + new Date().toISOString().split('T')[0];
    398398self.addEventListener('install', e => {
    399399  e.waitUntil(caches.open(CACHE_VERSION).then(c => c.addAll(['/'])));
     
    414414  if (e.request.method !== 'GET') return;
    415415  if (e.request.mode !== 'navigate') return; // page loads only
     416  // Same-origin ONLY. A cross-origin navigate request is an <iframe> embed
     417  // (YouTube/Spotify/SoundCloud …) — routing those through the SW yields an
     418  // opaque/altered response the iframe cannot render → blank embeds in the
     419  // installed PWA (which is always SW-controlled). Let the browser load them.
     420  try { if (new URL(e.request.url).origin !== self.location.origin) return; } catch (err) { return; }
    416421  e.respondWith(
    417422    fetch(e.request).catch(() => caches.match('/').then(r => r || Response.error()))
Note: See TracChangeset for help on using the changeset viewer.