PairDrop: Transfer Files Cross-Platform. No Setup, No Signup.
Only handle requests with the same origin via the service worker
schlagmichdoch31ec776fb304
diff --git a/public/service-worker.js b/public/service-worker.jsindex 47822ae7..e1f4f450 100644--- a/public/service-worker.js+++ b/public/service-worker.js@@ -151,7 +151,14 @@ const updateCache = request => new Promise((resolve, reject) => {// 2. If cache is not available: Fetch from network and update cache.// This way, cached files are only updated if the cacheVersion is changedself.addEventListener('fetch', function(event) {- if (event.request.method === "POST") {+ const swOrigin = new URL(self.location.href).origin;+ const requestOrigin = new URL(event.request.url).origin;++ if (swOrigin !== requestOrigin) {+ // Do not handle requests from other origin+ event.respondWith(fetch(event.request));+ }+ else if (event.request.method === "POST") {// Requests related to Web Share Target.event.respondWith((async () => {const share_url = await evaluateRequestData(event.request);