首页 > 解决方案 > 在 Lighthouse 中获取 Preconnect to required origins 错误

问题描述

我刚刚将我的静态网站移动到 AWS S3 + Cloudfront 和 Route 43。一旦我部署了我的网站,我就运行了 Lighthouse 和 Pagespeed Insights,我得到了“预连接到所需来源错误!”。 在此处输入图像描述 在我移动我的网站之前,我没有收到这个错误,所以我认为这与我的 AWS 配置有关。这是我的 index.html 文件中的预连接。

<link rel="preconnect" href="//www.google-analytics.com" crossorigin>
<link rel="preconnect" href="//fonts.googleapis.com" crossorigin>
<link rel="dns-prefetch" href="//fonts.googleapis.com">

我没有连接到任何其他 3rd 方,只有 Analytics 和 Google 字体。我是否缺少与云端的预连接?我在网上搜索了几天,还没有找到任何东西,所以我在这里。

标签: amazon-web-servicesamazon-s3amazon-cloudfrontpagespeedlighthouse

解决方案


如果您直接向您的 Cloudfront 域发出请求,那么您也需要预先连接到它。

我不肯定,但你的href标签值应该以 开头https吗?


推荐阅读