admin管理员组文章数量:1415460
I have a simple page hosted on locally that uses the bluetooth webAPI. When opening the page through localhost the script works as intended but when I connect to the server through using my IP on my puter or another it doesn't work, The error I got was: Uncaught TypeError: Cannot read properties of undefined (reading 'requestDevice')
.
I tried logging the Navigator object and saw that it had noticeably less properties on the remove connection than on the localhost, one of the missing properties was Bluetooth. Why does the Navigator object has less properties on the remote connection? and is it possible to fix it?
How it looks like on localhost:
How it looks like on remote connection:
I have a simple page hosted on locally that uses the bluetooth webAPI. When opening the page through localhost the script works as intended but when I connect to the server through using my IP on my puter or another it doesn't work, The error I got was: Uncaught TypeError: Cannot read properties of undefined (reading 'requestDevice')
.
I tried logging the Navigator object and saw that it had noticeably less properties on the remove connection than on the localhost, one of the missing properties was Bluetooth. Why does the Navigator object has less properties on the remote connection? and is it possible to fix it?
How it looks like on localhost:
How it looks like on remote connection:
Share Improve this question asked Aug 14, 2022 at 9:04 Guy LeviGuy Levi 455 bronze badges1 Answer
Reset to default 9According to https://web.dev/bluetooth/#https-only. Web Bluetooth is only available in secure browsing contexts. It means you either have to serve your webpage over https://
or localhost
such as http://127.0.0.1
or http://localhost
.
So it means you might want to always use https
, and http://localhost
is an exception for local development convenience.
本文标签: javascriptNavigatorbluetooth does not existStack Overflow
版权声明:本文标题:javascript - Navigator.bluetooth does not exist - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745179635a2646407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论