cybertec-postgresql / pgwatch

🔬PGWATCH: PostgreSQL metrics monitor/dashboard
BSD 3-Clause "New" or "Revised" License
73 stars 16 forks source link

WebUI is not working from remote host #526

Closed pashagolub closed 2 months ago

pashagolub commented 2 months ago

Discussed in https://github.com/cybertec-postgresql/pgwatch/discussions/523

Originally posted by **ondar** August 26, 2024 When I log in from another computer on the network, I get Undefined error after pressing login: ![image](https://github.com/user-attachments/assets/cf7e72a9-da69-4d2b-b3b6-bae30fdd3b3e) Seems UI is requesting response from localhost and not the remote server I run it from. Backend and Grafana seems to be working just fine. What am I doing wrong?
ondar commented 2 months ago

You can delete the 1st part about blank screen. That was already solved by you. Problem here is only 2nd part. Maybe next time I report errors I should do that separately 😁 Sorry for the confusion.

pashagolub commented 2 months ago

Would you please provide steps to reproduce the error? Thanks

ondar commented 2 months ago

Steps to reproduce:

  1. run pgwatch by included docker compose file on 1 computer in network
  2. connect to pgwatch UI from different computer on the network
pashagolub commented 2 months ago

Ough, now I need to buy one more computer.... ;-)

ondar commented 2 months ago

I tried that again with freshly built docker image about an hour ago.

ondar commented 2 months ago

I did that using 2 virtual computers on 1 physical. Maybe you can try it from phone connected to the same wifi?

ondar commented 2 months ago

I guess there is some setting in UI that represent endpoint of backend pgwatch that is currently set to http://localhost:8080. This setting needs to be dynamicaly derived from host you call UI from or maybe set manually when deployed by env variable to host's external IP and port? Calling backend from frontend is tricky 😁

pashagolub commented 2 months ago

ok, thanks. There was an easier way to reproduce the issue: http://127.0.0.1:8080/

ondar commented 2 months ago

But I guess it still works if it finds backend at localhost:8080, if you run it from different device where there is nothing on port 8080 it will throw timeout but this timeout just show error message "Undefined" (as there is nothing in response body I guess)?

ondar commented 2 months ago

Thanks for quick fix. It is working now.