https在实际应用中遇到的一些问题

205 阅读1分钟

1. Chrome中下载无效

在https的网站中,有个下载按钮,按钮的下载资源是http链接。下载功能可以在Edge和Safari浏览器中实现,但是Chrome点击后无效。

  • 分析原因

控制台报错如下:

查看Chrome版本更新的官方文档

从Chrome86的release note可以看到下图:

  • Insecure downloads will be blocked from secure pages in Chrome 84 through Chrome 88
    By Chrome 88, downloads from insecure sources will no longer be allowed when started from secure pages. This change will be rolled out gradually, with different file types affected in different releases:

即 从chrome84开始,从https网站下站http的可执行文件会出现警告。chrome85就直接报错,不允许执行了。

  • 解决方案

将下载链接修改为https.

2. window.showDirectoryPicker()无效

该API要求运行环境在https中。