HomeSmartMesh / smart_home_3d_webapp

interactive, 3d, video game like, overview and control of your home from a web app
MIT License
85 stars 11 forks source link

hue.discover CORS policy error #7

Open wassfila opened 4 years ago

wassfila commented 4 years ago

image

I do not understand why this started to happen, as I expected the discovery to be completely on the local network, why is an external site being requested.

Until clarified, the workaround is to hardcode the ip address in hue_app.js

image

wassfila commented 4 years ago

Philipps is providing an online service to dicover hue bridges inside your own house. According to the network locality principle of this project, it is better to avoid any dependency from external network. Therefore the ip address has to be configured by the user/developper, dropping the option of usability without knowing the ip address. A local discovery can be implemented in the future.

solution for the CORS issue is to add 'no-cors' in the header, but then the body is empty, so Philipps kind of restricted the usage of the service to the same origin.

fetch("https://www.meethue.com/api/nupnp",{mode: 'no-cors'})
.then(response => {return response.text()})
.then(data => console.log(data))
wassfila commented 4 years ago

Philipps provides a method for discovery from the local network https://www.burgestrand.se/hue-api/api/discovery/

The provided solution that runs locally requires ssdp protocol for which a client library exists https://github.com/diversario/node-ssdp

like most client libraries, they're common to node.j and front end, therefore only implemented with "require" which makes the transpilation a necessary step.