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

出于安全原因,您的服务工作人员无法拦截该通信。

相关问题