BUG? Environment variable not always working in HTTP Node (GET works, POST fails)

I am trying to pass a host environment variable to HTTP Node in n8n.

It works fine for Webhook nodes, and also for HTTP Node (GET request).
But on POST request, it fails with Invalid URL.


:hammer_and_wrench: Setup:

.env:

HH_NINJA_URL=http://172.18.0.100:8000

docker-compose.yml:

  n8n:
    restart: always
    image: n8nio/n8n:1.86.1
    container_name: n8n
    environment:
      WEBHOOK_URL: https://webhook.url.com/
      HH_NINJA_URL: ${HH_NINJA_URL}
      N8N_LISTEN_ADDRESS: 0.0.0.0
      N8N_TRUST_PROXY: true
      N8N_BASIC_AUTH_ACTIVE: true
      N8N_PERSONALIZATION_ENABLED: true
      N8N_USER_MANAGEMENT_DISABLED: false
      N8N_DEFAULT_LOCALE: en
      DB_TYPE: sqlite
      DB_SQLITE_FILE: /home/node/.n8n/database.sqlite
      N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: true
      N8N_RUNNERS_ENABLED: true
    volumes:
      - n8n_data:/home/node/.n8n
      - ./n8n/prompts:/home/node/prompts
    networks:
      - external_network

:white_check_mark: Inside n8n container check:

printenv | grep HH
# HH_NINJA_URL=http://172.18.0.100:8000

curl -X GET ${HH_NINJA_URL}/api/v1/ai-llm/internal/resumes/5
# {"user_id":5,"resumes":[...]} âś…

curl -X POST ${HH_NINJA_URL}/api/v1/ai-llm/internal/assistant -H "Content-Type: application/json" -d '{"user_id": 5, "assistant_id": 777}'
# {"success":true,...} âś…

In n8n:

  • First HTTP Node (GET): works:white_check_mark:
  • Second HTTP Node (POST): fails with "Invalid URL":x:

:question:Question

Why does it work inconsistently between HTTP nodes (GET vs POST) even though the environment variable is correctly defined and available?

n8n community edition 1.86.1

Hey nucjag!

To me it looks like that on the workflow your shared the Post request Node has the URL expression is still in “fixed” mode, to use env variables like this you need to turn it to the “expression” mode to have the string concatenation work!

Does this workflow work?

1 Like

yes… i am new to n8n and this “switch” was not visully clear for me

maybe n8n team can do it in different colors -

lets say - in fixed mode it is blue , in expression - orange…

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