hvxl / otmonitor

Monitor tool for the OTGW (http://otgw.tclcode.com/)
GNU Lesser General Public License v3.0
27 stars 10 forks source link

Update websocket regex in javascript code to match the full url when proxied through nginx #15

Closed fliphess closed 3 years ago

fliphess commented 3 years ago

Hello sir,

When I'm using otmonitor in the home assistant addon, otmonitor is embedded in the home-assistant application. As a result all requests are proxied through nginx from an endpoint location that contains random upper and lower chars and an underscore.

The url endpoint location when proxied is for example: $hostname/api/hassio_ingress/ERFaegsGr54tw5y4sgerga/status.html but the websocket connections are tried to $hostname/status.ws.

The regex for matching the websocket url from the page uri does not include those chars and matches only lowercase until the first /, which is why the ws connections errors out with a 404.

WebSocket connection to 'wss://$hostname/status.ws?var=gui&var=error' failed: Error during WebSocket handshake: Unexpected response code: 404

By "widening" the regex matching A-Z_/ too, I'm trying to use up until the last / of the url instead of the first one, which allows connecting to the websocket even when proxied through an endpoint.

hvxl commented 3 years ago

Looks like a good addition to me. Thanks.