meshtastic / js

JS/TS library for interfacing with Meshtastic devices
https://meshtastic.org
GNU General Public License v3.0
65 stars 33 forks source link

fix: allow an opaque response in ping() #63

Closed jstarpl closed 1 year ago

jstarpl commented 1 year ago

When using the library to connect to a Meshtastic radio, the Ping method attempts to fetch from hotspot-detect.html. Unlike the /api endpoints, the Meshtastic device HTTP server doesn't set any CORS headers on the hotspot-detect.html response. As a result, the PING will fail:

PING failure in Chrome Inspector

Since meshtasticjs doesn't actually check the response from the server in this instance - just needs the request to go through, we can use mode: no-cors and allow this fetch to resolve successfully.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

sachaw commented 1 year ago

Nice fix, strange thing is, the firmware should be setting those headers, so idk, either way this works great.