Proper way to access some shared variable?

I’m planning to build several workflows that will be calling same URL, this URL will be changing from time to time. I’m trying to find proper way to handle this without hardcoding URL in each workflow. (I’m on self-hosted by the way)
I’ve found two solutions:

  • use $env variable
  • use Execute Workflow with some dedicated workflow with Set node used as first step in all other workflows
    I think first solution is quicker to execute, but second solution seem to be more n8n-way.
    Is there much overhead when calling another workflow? Is there any other, even simpler way to achieve my goal?

Hi @Yuriy_Klyuch! Tbh I recommend your personal preference here, because at the end of the day n8n workflows should work for you and not the other way around. So if you’re happy with environment variables I’d say go for it :smiley:

There is a very small overhead when calling another workflow as this means two additional nodes would have to be executed (each of which would keep their execution data in memory). The amount would typically be negligible though if all you’re passing on is a URL.

Personally I tend to connect a PostgreSQL database to my n8n instances. This acts as a data store (for example for keeping track of items I am processing in my workflows) but could also serve as a global store for configuration options (such as URLs). So perhaps this could be an approach for you as well.

thanks for answering. You mean general node with connection to PostgreSQL for read/write some data I need to share?

Yes exactly, I am using the n8n Postgres node for this. It’s just a suggestion though, there’s no right or wrong approach here.