How to find out URL of node-red inside a node?

Hi,
I want to receive a HTTP GET inside my own node like the HTTP-in does it as follows:

RED.httpNode.get('/myprivateroute', cookieParser(), httpMiddleware, corsHandler, metricsHandler, callback, errorHandler);

My question is: how can I determine the full url which is accessible from the local network?
"http://IP:PORT/myprivateroute"

I found out that the PORT number can be extracted from
"RED.server._connectionKey"
, however the IP cannot be found there. Any ideas?

Hi, what is the reason for wanting to know the IP and port? what is the end goal? Perhaps there is an other / better approach?

NOTE: The IP 127.0.0.1 will obviously work but which IP (or IPs) node-red is accessible on is a completely different kettle of fish (even IF you could get the IP addresses, you still dont know if the IP or Port is blocked by a firewall or non routed for example)

Much of this information is in RED.settings already.

However, the whole thing is complex and has some things to catch you out. I spent quite a lot of time trying to get this right for uibuilder vNext with input from others on dealing with things like what happens when you are behind a reverse proxy.

Thanks, for trying to help to find an alternative, but I simply need the url with ip and port that‘s all. Instead of the IP, the hostname would be ok, too.

Ah ok I see your point, but it is only about devices communicating inside a local network… no internet

are you trying to access the endpoint from within the same nw segment?

if yes, you might want to have a look at this:

@lu4t thanks, I will have a look into the mdns module.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.