How do I get IP address?

I’m trying to get my project IP, but since this can change, I need a way to do this through nodejs.

require("child_process").execSync("echo "$(ping -c 1 -f ${PROJECT_NAME}.glitch.me) > cur_ip.txt")

^ that will set the new ip every time the script is started/restarted


also, here is how to find that ip:
url.ur.pinging ( IP_HERE )...

2 Likes

For me there is 4 (four) different possible addresses

install dns package and do this

const require('dns');

dns.resolve4(`http://${process.env.PROJECT_DOMAIN}.glitch.me`, (err, addresses) => {
  if (err) console.log(err)
  console.log(addresses)
})

You will have an array of four different ip

To make it clear, I didn’t try Jonyk56 method, so maybe his solution is better haha

2 Likes

hm, i have never heard of that package, well, time to go hijack my home computer with a linux vm!
with that package

@Jonyk56 your thing doesn’t seem to work… It seems that “child-process” doesn’t exist?

@wolfy01 did you try the method I told you?

darn, i never remember the module name, shall fix mine in a minute!

ok, fixed it!

this is how you get your project IP Address using your glitch project console :slight_smile:

curl ifconfig.me

image

@rizuwan86 Thank you, but I was looking for a way to do this in nodejs

maybe you can make a request like promise to the url and get the result instead…

You could open CMD prompt and enter tracert www.yourdomainhere.com