Ritwik Kumar
Ritwik Kumar

Reputation: 177

Workbox Service worker

I am getting below console error :- Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode

I am using below code for cache all request which consist xy/xyAPI/api :-

workbox.routing.registerRoute(
  new RegExp('xy/xyAPI/api'),
  workbox.strategies.networkFirst({
    cacheName: 'api-url',
    plugins: [
      new workbox.expiration.Plugin({
        maxEntries: 20,
        maxAgeSeconds: 24 * 60 * 60
      }),
      new workbox.broadcastUpdate.Plugin('api-url', {
        headersToCheck: ['date'],
      })
    ]
  }));

Upvotes: 2

Views: 259

Answers (1)

thecodejack
thecodejack

Reputation: 13379

Looks like this is chromium bug. You can check the logged issue details here https://bugs.chromium.org/p/chromium/issues/detail?id=823392

Upvotes: 1

Related Questions