javascript - Navigator.bluetooth does not exist - Stack Overflow

I have a simple page hosted on locally that uses the bluetooth webAPI. When opening the page through lo

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 badges
Add a ment  | 

1 Answer 1

Reset to default 9

According 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745179636a4615360.html

相关推荐

  • javascript - Navigator.bluetooth does not exist - Stack Overflow

    I have a simple page hosted on locally that uses the bluetooth webAPI. When opening the page through lo

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信