Bluetooth requestDevice() 在 Amazon Lightsail 上未定义

Bluetooth requestDevice() is undefined on Amazon Lightsail

以下示例 (1) 在 Chrome 版本 70 中作为文件打开时列出了可用的蓝牙设备。

将完全相同的示例上传到 Amazon Ligtsail 实例时,我收到以下错误消息:

Uncaught TypeError: Cannot read property 'requestDevice' of undefined
at connect ((index):9)
at HTMLButtonElement.onclick ((index):4)

任何人都可以向我解释可能是什么问题吗?既然是JavaScript,应该是在浏览器中执行,与任何服务器设置无关?

.

(1) 在 Amazon Lightsail 上生成错误的示例代码

<html>
<body>
<button onclick="connect();">Click here</button>
<script>
function connect() {
    console.log('Getting Bluetooth Device...');
    navigator.bluetooth.requestDevice(
    {
        acceptAllDevices : true
    })
    .then(device => {
        console.log('Got device');
    })
     .catch(error => {
        console.log(error);
    });
 }
</script>
</body>
</html>

正如@kdgregory 所建议的,navigator.bluetoothHTTPS only:

Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.

我添加了一个 GitHub pages 并且有效。