I’m trying to get a very simple Bonito (v4.0.0) app running, and I must be doing something horribly wrong because it’s not working well. Starting from Deployment · Bonito (simondanisch.github.io)
using Bonito, Bonito.Observables
import Bonito.TailwindDashboard as D
app = App(DOM.div(D.Slider("nsamples", 1:200, value=100)), title="hello world")
port = 9384
url = "0.0.0.0"
server = Bonito.Server(app, url, port)
but when I put in my own IP, as in http://MY_IP_ADDRESS:9384, it looks different, and the interactivity is broken (i.e. the nsamples number does not change when I move the slider)
I tried Genie, Oxygen, Mux (!) and Python’s Dash and they all have the same behaviour of loading a static page when accessed through MY_IP_ADDRESS:port. I’m going to blame the firewall unless new information comes to light.
This means that when Bonito receives the request, it looks like http://localhost:8081/ so it does not know what’s the server name. For all it knows, it looks like it’s being serving localhost so in the html page that it generates, it gets the javascript file with
But since your web browser that it reading that html file is not on the server where localhost:8081 would work, you need to use http://132.10.187.234. By using the proxy setting, Bonito is aware that he’s seeing localhost only because it’s being redirected by nginx or similar and that in the webpage that is being served, it should use the original url instead.
So it then writes the following which works:
I still wish to get rid of the proxy_url with relative urls and maybe some JS magic, but even than it may be needed, e.g. for JuliaHub VSCode integration, where the plotpane is a div inside a huge complex html site (VSCode online) and the bonito connection needs to be proxied through a completely different URL…
Unless we put the Bonito plotpane output in an iframe, but even than, how to figure out the URL of the iframe?
But it could be still worth it to try reduce the cases where one needs to set it.
It’s just a bit of work, and I’ve noticed url schemes are quite sensitive to different browsers/contexts, since the way urls are interpreted doesn’t seem to be completely straightforward (note that this needs to work for Documenter, IJulia, VSCode, a Server, a fragment on a page, Pluto etc).
FWIW Genie.jl (as well as some Python package I tested) worked immediately on our server, without having to specify the server. Not sure how they achieve this.