Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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 computer 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:
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.
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.