Only handle requests with the same origin via the service worker
This commit is contained in:
parent
4862ba3067
commit
31ec776fb3
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue