workbox

How to allow cookies and handle 302 redirects with workbox service worker tools?

℡╲_俬逩灬. 提交于 2021-01-28 02:43:23
问题 I have a SSR based react app and at present implementing Workbox tools for precaching and offline capabilities into it. I ran into issues mainly because the site relies on cookies at server side and issues redirects based on these. Initial load works fine, but once service worker(sw) is online and another refresh results in sw doing a fetch call with the url from within workbox source. During this time, the server doesn't find cookies(fetch doesn't carry credentials - link) and issues a

Workbox 5 syntax error - Uncaught TypeError: workbox.expiration.CacheableResponsePlugin is not a constructor

隐身守侯 提交于 2021-01-27 06:27:08
问题 I'm trying to set up a simple Service Worker for a small static site. precache a couple of pages. cache *.html files for just 5 mins cache all other files for 30 days handle 404 and offline status with an offline page. I get service worker console error sw.js:59 Uncaught TypeError: workbox.expiration.CacheableResponsePlugin is not a constructor this is at the line new workbox.expiration.CacheableResponsePlugin({ Any suggestions on how to fix this would be appreciated. /** * Welcome to your

Nextjs and workbox integration

浪子不回头ぞ 提交于 2021-01-04 05:41:22
问题 Requirement : I am trying to use service worker and cache static files so as to have a benefit to reduce HTTP requests and make the site performance better. Down the lane I would switch to offline, caching images, api's etc. I have seen the plugins: https://github.com/hanford/next-offline and https://www.npmjs.com/package/next-pwa It seems to work. Although I was trying to find out if there were examples of (nextjs + workbox) . Next js do have an example for https://github.com/vercel/next.js

Workbox web worker caching and causes duplicate network calls

好久不见. 提交于 2020-12-16 04:48:53
问题 I have implemented the caching using the following code: require("dotenv").config() const workboxBuild = require("workbox-build") const { COUNTRY: country, NODE_ENV } = process.env const urlPattern = new RegExp(`/${country}\/static|_next\/.*/`) const buildSW = () => { return workboxBuild.generateSW({ swDest: "public/workbox-worker.js", clientsClaim: true, mode: NODE_ENV, skipWaiting: true, sourcemap: false, runtimeCaching: [ { urlPattern: urlPattern, // Apply a cache-first strategy. handler:

Generate ServiceWorker using webpack 4.41 and workbox 6

痴心易碎 提交于 2020-12-15 00:44:37
问题 I am using webpack v4.41 and workbox v6 to create my service-worker.js . I am having trouble regitering the service worker in my dev environment. I have set devtools.serviceWorkers.testing.enabled to true I have followed the instructions for using bundlers with workbox, read the documentation for injectManifest and adding the Workbox webpack plugin. After building using webpack (generating serviceWorker.js) Firefox reports error: Service worker error TypeError: ServiceWorker script at http:/

Adding a new header to a Request, while preserving the body

懵懂的女人 提交于 2020-12-09 09:50:28
问题 I am setting up a PWA for my company in house usage. What method should I use to attach a bearer token to all of the requests from dom or web-worker. This method that I am using works as expected when posting a form or json but I would like a cleaner or friendlier method as I don't trust that the text fallback will suffice. I was looking for a function in Google's workbox.js service worker module to see if I could set up a intercept to always append the Bearer token when a request gets made

Local share target handler with workbox ony works if PWA recently active

喜你入骨 提交于 2020-12-08 04:04:59
问题 I use workbox in my serviceworker to handle requests to a share-target url (defined in manifest.json ) locally (offline). On Android, once added to home screen (A2HS) from Chrome, my app is available as share-target, for image files, to other apps. The implementation generally works perfect. my share-target handler stores the received files in browser-cache and redirects to a follow-up /share route (which then handles pictures from cache) locally. But from time to time, the serviceworker

Webpack workbox Can't find self.__WB_MANIFEST in your SW source

别来无恙 提交于 2020-06-17 15:23:14
问题 I migrate from v4 to v5 of webpack-workbox-plugin but when I try to build, I got error: ERROR in Can't find self.__WB_MANIFEST in your SW source. Child InjectManifest: Asset Size Chunks Chunk Names sw.js 1.5 KiB 0 [emitted] InjectManifest Child html-webpack-plugin for "index.html": 1 asset Do __WB_MANIFEST will create in a precach-manifest file and import automatically like v4? WebpackConfig : new WorkboxPlugin.InjectManifest({ swSrc: 'sw.js', chunks: ['*.chunk.js'], exclude: [/\.(?:png|jpg

Webpack workbox Can't find self.__WB_MANIFEST in your SW source

ぐ巨炮叔叔 提交于 2020-06-17 15:23:13
问题 I migrate from v4 to v5 of webpack-workbox-plugin but when I try to build, I got error: ERROR in Can't find self.__WB_MANIFEST in your SW source. Child InjectManifest: Asset Size Chunks Chunk Names sw.js 1.5 KiB 0 [emitted] InjectManifest Child html-webpack-plugin for "index.html": 1 asset Do __WB_MANIFEST will create in a precach-manifest file and import automatically like v4? WebpackConfig : new WorkboxPlugin.InjectManifest({ swSrc: 'sw.js', chunks: ['*.chunk.js'], exclude: [/\.(?:png|jpg