[SOLVED] Webview wont load in Basic UI - Refused to connect

Hi

As the topic title says, when viewed in basic ui my web view wont load. Chrome says, refused to connect, however on the android app it loads just fine.

I can also load the html page if I hit the url in chrome just fine.

Webview url="https://myfqdn/static/Media.html" height=6

I should note I have nginx in front of openhab doing ssl on port 443.

In edge I get a different message saying

There is supposed to be some content here, but the publisher doesn’t allow it to be displayed in a frame. This is to help protect the security of any information you might enter into this site.

Any ideas why this wont load in Basic UI.

Are you using BasicUI through myopenhab when this happens? Webview is not proxied through myopenhab.

I’m not using myopenhab no. I can see a header being set which is possibly causing it.

x-frame-options: DENY

Trying to override in nginx but no luck so far.

proxy_hide_header  x-frame-options;
proxy_set_header   x-frame-options      allowall;

Just tested without nginx in front and I get the same experience. So that header is coming from openhab. Makes me think that it would break WebView for everyone though.

perhaps try this method, this is cut and pasted so may read a little funny…

To serve html files we are going to use a built in feature of Openhab that allows us to access these files with the url format http://OpenhabServerIP:8080/static/allcams.html
The file must be placed inside a folder called html which can be found with the default samba share that openhabian creates called ‘openHAB2-conf’. If you use VS code to edit your Openhab files you already know the location of this folder.

Ok I’ve fixed it.

I have a standard include for hardening the nginx config, it includes all my ssl settings as well as and wait for it… X-Frame-Options DENY;

I’ve simply overrode this with adding

add_header X-Frame-Options SAMEORIGIN;

In my nginx config for openhab and all is good once again.

Thanks for the help.

Chris

1 Like

I had a similar issue but it was due to my grafana setup. In order to allow browsers to render Grafana in a

<frame>, <iframe>, <embed> or <object>

go to the configuration file and change “allow_embedding = true” and restart the grafana server. The default is false.

3 Likes

I am running into the same trouble here.

I have added some grafana graphs into my Sitemap which works fine on my local network.

Webview url="http://192.168.0.xx:3001/d-solo/xxx/xxx?orgId=1&panelId=6\" width=\"450\" height=\"200\" frameborder=\"0\" refresh=2000" 

on my nginx config, I use
location /

to forward to my OH instance. Also this works fine - except for the grafana content.

I am accessing via Android - could it be that android is still trying to load date from the internal IP instead of the external?

When I look in the Nginx access log, I see:

no request that I could associate with the request to access grafana.

I have tried adding your suggested parameter - but no change at all…

Grafana sits on the same server as OH on a different port.

"allow_embedding = true”
That solved the issue for me! Thanks for posting