near / near-wallet

Web wallet for NEAR Protocol which stores keys in browser's localStorage
https://wallet.near.org
MIT License
218 stars 174 forks source link

UI (Local NEAR Wallet) does not work on localnet when accessed remotely #2516

Open andrew-sol opened 2 years ago

andrew-sol commented 2 years ago

Problem I followed this guide: https://docs.near.org/docs/tools/kurtosis-localnet But I did the setup on a separate Linux machine that is connected to my local network.

The problem is that the UI opens in my browser when I access it via http://192.168.88.112:49162 but it sends all requests to http://127.0.0.1:49159. Look at the screenshot.

Screenshot 2022-03-04 at 13 36 13

Expected Behavior Domain IP address is not hardcoded and all the request URLs are relative to the current domain.

andrew-sol commented 2 years ago

Well, the issue exists in other UI tools as well (Explorer).

If someone is interested, I overcame the issue by using a simple NodeJS script for forwarding a bunch of ports used by Kurtosis (the ports might be different for each user).

mkdir near-port-forward && cd near-port-forward
yarn add http-proxy
touch main.js

main.js:

const httpProxy = require("http-proxy");

const ports = [];

for (let port = 49158; port <= 49162; port++) {
  ports.push(port);
}

// forward the ports
ports.forEach((port) => {
  console.log(`Forwarding port: ${port}`);

  httpProxy
    .createProxyServer({ target: { host: "192.168.88.112", port }, ws: true })
    .listen(port);
});

Run:

node main.js

The script has to be run from the local machine.

ghost commented 1 year ago

Alternatively, you could update the config on near-cli directly https://github.com/near/near-cli/blob/47e656177135b27e738c593c6e6960dbdfc7ad2d/config.js#L68