Sensor Widget JS Not Working in Safari (Desktop, Mobile)

Just to clarify @jollyturns, are you referring to the one I pasted above or the one referencing an internal WAN IP? If it’s regarding the https://www.purpleair.com/widget.json endpoint, then it should be perfectly fine regarding CORS issues (unless there’s a particular CSP rule applied on the local domain, likely under the dev’s control anyway). That domain (at least that widget.json endpoint) is emitting the necessary Access-Control-Allow-Origin: * headers and works just fine across domains. In fact, it’s necessarily built that way, since it was created explicitly for use in embedding in people’s websites (it exposes both regular json and the jsonp callback format).

I happen to know this because I’ve already built my own widget which reverse engineered the API for my own personal site for my own personal sensor (just for fun) :grimacing:. It’s incomplete so I didn’t want to share it for that reason, but probably more importantly, also because the API wasn’t built for that purpose (I figured sharing it could cause issues if they decided to change it, I didn’t want to ruin it for everyone by forcing PurpleAir’s hand there). Let’s just say it’s not locked down; just extremely obtuse, lol. Probably intentionally so.

Anyway: Turns out PurpleAir does provide access to a great API which is a fair bit more straight forward than utilizing the widget.json and it is effectively* free; the only minor issue there is that if you wanted to keep it entirely client side (without a server side script of some sort to proxy it for you) then you’ll expose your keys. Here’s their pricing info: API Pricing

* Disclaimer: The reason I say “effectively free” (at least at first) for personal use is because they start you off with 1,000,000 “points” when you first sign up. So if you’re querying/caching your own sensor properly then it’s probably fine to use it for a fairly long time. Very hand wavy there… but I’d prefer the public API for other reasons though (noted above); not just because of the artificial expiration on accessing my own sensor data due to this cap (or requirement to pay, which is reasonable for a public service, to be fair). However, that said – they are working on it (see lower in that thread).