Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Application not working via SSH Tunnel #1498

Open
Chasbrot opened this issue Jan 6, 2025 · 1 comment
Open

Web Application not working via SSH Tunnel #1498

Chasbrot opened this issue Jan 6, 2025 · 1 comment

Comments

@Chasbrot
Copy link

Chasbrot commented Jan 6, 2025

Describe the bug
The Web Application is not working when accessing a device via an SSH tunnel. The main webapp site loads but no interaction is possible and no values are displayed.

The main problem is that the device reports its own IP address in the answer to the initial request to /app? :

<!DOCTYPE html>
<html>
    <head>
        <title>OpenBK_Ventilator</title>
        <link rel='shortcut icon' href='data:image/gif;base64,R0lGODlhEAAQALMAABEHBLT+BJxCBFgmBHx6fKxKBCQiJCIWC/ppBJSWlNTS1Pv9+0xmBDo7Oow6BNlZBCH5BAEAAAsALAAAAAAQABAAAwRzcMm5UqKYtjFalkpjEACCAITRKJrwHOV5PII3GQ/yAM+ePwYKYYYoOBwF3YEwaQCehQODcSg8AZ7EwPRwMAIBhiOHGFi2Oi9YTDYvnFAp1fq0LYY5I1LJvP14PjpBTS4wJgAzNRQhIzEoKiwfGx0fGRYfEQA7'/>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
        <meta name="robots" content="none">
        <script>
            var root = 'https://openbekeniot.github.io/webapp/'
              , device = 'http://10.0.0.115';
        </script>
        <script src='https://openbekeniot.github.io/webapp//startup.js'></script>
    </head>
    <body></body>
</html>

The device IP is saved into the global variable window.device and used for reference in all subsequent requests. If a tunnel is used, this IP is not reachable.

A workaround is possible via the browser console:
window.device="<correct local ip and port>"
or
window.device=""

The second one works because the browser directs the request to the current URL and therefore uses the correct IP.

The "normal simple" UI on /index works fine.

Firmware:

To Reproduce

  1. Open SSH Tunnel to some server/device
  2. Connect via the tunnel to the OpenBK web ui
  3. Launch web app

Screenshots
image

Additional context
Yes I know it is a niche problem, but I still would be very happy if someone would take a look at this. Thank you very much, this project is really great.

@jekader
Copy link

jekader commented Jan 6, 2025

Should be an easy fix - just compute the URL via window.location instead of hardcoding it: https://www.w3schools.com/js/js_window_location.asp

This should fix NAT and other strange tunnel scenarios with custom IPs, ports, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants