Get hostname of current n8n instance?

I have a couple of webhook routers built in n8n. Basically based on a parameter attached to an incoming webhook the router will make an http post to another workflow. In an effort to make these more portable, I thought I would make these post modules use the existing hostname name instead of being hardcoded in.

Normally in JS I would do something like ‘location.hostname’ but when I run this I get “location is not defined”.

Is there a local var for this or another way to get this info?

I discovered using “localhost” in the url works.

2 Likes

You can also get it from the environment variables (docker based install)

Interesting. I’m on a docker install. How would I reference these in a node?

How to define custom environment variables available in the n8n workflow - Questions - n8n
{{$env.NODE_ENV}} in a Set node

1 Like