From c9590abd188a10d6391dffe6b89ae5c855b19673 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Oct 2021 22:07:48 -0500 Subject: [PATCH] ServiceWorker: don't redirect API routes with appShell --- webpack/production.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/webpack/production.js b/webpack/production.js index f3aaaaafe..38870ff89 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -81,10 +81,35 @@ module.exports = merge(sharedConfig, { 'packs/emoji/**/*', ], ServiceWorker: { + cacheName: 'soapbox', // entry: join(__dirname, '../app/soapbox/service_worker/entry.js'), - // cacheName: 'soapbox', minify: true, }, + cacheMaps: [{ + match: requestUrl => { + const backendRoutes = [ + '/api', + '/pleroma', + '/nodeinfo', + '/socket', + '/oauth', + '/auth/password', + '/.well-known/webfinger', + '/static', + '/main/ostatus', + '/ostatus_subscribe', + '/pghero', + '/sidekiq', + ]; + + const isBackendRoute = ({ pathname }) => { + return backendRoutes.some(pathname.startsWith); + }; + + return isBackendRoute(requestUrl) && requestUrl; + }, + requestTypes: ['navigate'], + }], safeToUseOptionalCaches: true, appShell: join(FE_SUBDIRECTORY, '/'), }),