0

我發現我對Google API的請求不會觸發服務工作人員抓取事件。靜態資源和其他API的獲取按預期觸發事件。未由Google API請求觸發的服務工作人員抓取事件

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

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

我一直沒能找到任何文件表明這是由設計。

是否有人能夠解釋爲什麼Google API請求不會觸發提取事件?這可能與oAuth有關嗎?

回答

3

,可以檢查DOM和發現,谷歌的OAuth lib中注入一些無形 s轉換你的頁面,像這樣的:

<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> 

這些 s的用於所有使用谷歌API的網絡通信。請注意,來自https://accounts.google.com來源,因此這些呼叫是從服務工作者的範圍之外進行的(僅適用於https://laurieboyes.github.io)。

出於安全原因,您的服務工作人員無法攔截該通信。

相關問題