簡體   English   中英

服務工作者獲取事件未由Google API請求觸發

[英]Service worker fetch event not triggered by Google API requests

我發現我對Google API的請求不會觸發service-worker fetch事件。 靜態資源的獲取以及對其他API的獲取將按預期觸發該事件。

演示: https//laurieboyes.github.io/test-gapi-sw/

演示代碼: https : //github.com/laurieboyes/test-gapi-sw/blob/master/index.html

我沒有找到任何暗示這是設計使然的文檔。

有誰能解釋為什么Google API請求不觸發獲取事件? 可能與oAuth有關嗎?

您可以檢查DOM並注意到Google的OAuth庫將幾個不可見的<iframe>注入到頁面中,如下所示:

<iframe name="oauth2relay368346125" id="oauth2relay368346125" 
  src="https://accounts.google.com/o/oauth2/postmessageRelay?parent=https%3A%2F%2Flaurieboyes.github.io&amp;...&amp;forcesecure=1"
  tabindex="-1" aria-hidden="true" 
  style="width: 1px; height: 1px; position: absolute; top: -100px;">
</iframe>

這些<iframe>用於與Google API的所有網絡通信。 請注意, <iframe>源自https://accounts.google.com的來源,因此這些調用是在服務工作者的范圍之外進行的(僅在https://laurieboyes.github.io內有效)。

您的Service Worker出於安全原因無法截獲該通信。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM