mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-05 17:33:49 +00:00
Only handle requests with the same origin via the service worker
This commit is contained in:
@@ -151,7 +151,14 @@ const updateCache = request => new Promise((resolve, reject) => {
|
|||||||
// 2. If cache is not available: Fetch from network and update cache.
|
// 2. If cache is not available: Fetch from network and update cache.
|
||||||
// This way, cached files are only updated if the cacheVersion is changed
|
// This way, cached files are only updated if the cacheVersion is changed
|
||||||
self.addEventListener('fetch', function(event) {
|
self.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.
|
// Requests related to Web Share Target.
|
||||||
event.respondWith((async () => {
|
event.respondWith((async () => {
|
||||||
const share_url = await evaluateRequestData(event.request);
|
const share_url = await evaluateRequestData(event.request);
|
||||||
|
|||||||
Reference in New Issue
Block a user