I’m working on incorporating the ingress capability of Home Assistant into an add-on that utilizes a websocket. The challenge is that the web application expects a base URL of / but the Home Assistant ingress feature uses a base URL of /api/hassio_ingress//. The web application utilizes a websocket at /live. I’ve setup NGINX to provide the necessary proxying and filtering in order to dynamically modify the URL references in the web application. This seems to work well for the main page, but there are two secondary pages that don’t work. When I look at the Messages for the websocket in the developer tools, I see that the websocket is sending a phx_reply with a “join crashed” error.
At this point, I’m hoping someone might have some ideas as to why it might work on the main page but not on the secondary pages.
Can you provide the full error message and the relevant code?
The application is TeslaMate (https://github.com/adriankumpf/teslamate). The prod.exs sets the root to “.”, which then causes all of the endpoints defined in the app to start at /. I’m basically looking for a way to dynamically change that root path.
Home Assistant provides a request header X-Ingress-Path that contains the root path that is actually used (e.g. /api/hassio_ingress/id_of_addon). As such, I’m looking a way to cause Phoenix to utilize that new root path in the artifacts that are generated.
I read about one possible solution of setting
X-Forwarded-Host to something like “localhost:8080/api/hassio_ingress/id_of_addon”. Would Phoenix process that in the way I’m looking for? If not, are there any other headers that Phoenix looks at that might cause it to change it’s root path?