Redeploying flows while having Editor Authentication enabled

Hi everyone!

I'm still relatively new to Node-RED and I’ve hit a roadblock in a project. I’m hoping someone here can help me figure it out.

I'm trying to automate the redeployment of flows through the Node-RED API. Initially, I had a containerized setup with no authentication enabled. Everything worked as expected: I would click an inject node, and it would trigger the flow redeployment. The flow I’m using is included below.

However, the issue started when I enabled authentication. I updated my settings.js to include adminAuth, and while the login screen works fine, the redeployment flow has stopped working. The inject node no longer seems to trigger the actual redeployment, and I don’t see the expected message in the debug node.

I’ve tried various changes and troubleshooting steps, but nothing seems to resolve it.
(trying to turn off API authentication and using allowed IP's restriction and trying to pass the login info in the http request node)

Has anyone run into this issue before? How should I modify the flow to work with authentication enabled?

Thanks in advance for your help!

[
    {
        "id": "fd211699eeb8a572",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "09597665314e9c08",
        "type": "inject",
        "z": "fd211699eeb8a572",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 540,
        "y": 280,
        "wires": [
            [
                "1d43688fa058eb14"
            ]
        ]
    },
    {
        "id": "b8f5e6151ca3bd0d",
        "type": "comment",
        "z": "fd211699eeb8a572",
        "name": "Redeploy!",
        "info": "",
        "x": 780,
        "y": 240,
        "wires": []
    },
    {
        "id": "1d43688fa058eb14",
        "type": "delay",
        "z": "fd211699eeb8a572",
        "name": "",
        "pauseType": "delay",
        "timeout": "500",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 690,
        "y": 280,
        "wires": [
            [
                "e220e37a36fa10e6"
            ]
        ]
    },
    {
        "id": "e220e37a36fa10e6",
        "type": "function",
        "z": "fd211699eeb8a572",
        "name": "Redeployer",
        "func": "// Set the API endpoint\nmsg.url = \"http://localhost:1880/flows\";\nmsg.method = \"POST\";\n\n// Headers required for a reload deploy\nmsg.headers = {\n    \"Content-Type\": \"application/json; charset=utf-8\",\n    \"Node-RED-Deployment-Type\": \"reload\",  // triggers a \"Restart Flows\" deploy\n    \"Node-RED-API-Version\": \"v2\"\n};\n\n// Minimal payload (flows are reloaded from disk)\nmsg.payload = { \"flows\": [{}] };\nnode.warn(\"Changes have been made! This Flow has been redeployed!\");\n\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 850,
        "y": 280,
        "wires": [
            [
                "b6204eeabb2d0ef2"
            ]
        ]
    },
    {
        "id": "b6204eeabb2d0ef2",
        "type": "http request",
        "z": "fd211699eeb8a572",
        "name": "",
        "method": "use",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://localhost:1880/flows",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "basic",
        "senderr": false,
        "headers": [],
        "x": 1010,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "5ba406237e18f855",
        "type": "debug",
        "z": "fd211699eeb8a572",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 480,
        "wires": []
    },
    {
        "id": "a77ba310b37858fe",
        "type": "inject",
        "z": "fd211699eeb8a572",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 710,
        "y": 480,
        "wires": [
            [
                "5ba406237e18f855"
            ]
        ]
    }
]

(I'll bite)

I am not understanding what you mean, or want to do here.

When you DEPLOY a flow it runs. Why do you need to REDEPLOY it?

What result do you want to happen?

I fear/suspect you may be trying to do what you want the wrong way.

Nothing wrong with that. You have to start somewhere.

But to maybe help others better understand what you want to do in this case.

Also - looking at what part of the flow I can see - I'd suggest maybe including a screen shot of what it looks like from the node point of view.

A lot of people may be weary of importing foreign nodes.

Just to clarify the context a bit:

The main flow I’m working with includes an OPC UA Client node with active subscriptions. I ran into an issue where I couldn’t reliably remove unwanted subscriptions — the node kept outputting data from tags I no longer needed.

As a workaround, I found that redeploying the flow would reset the OPC node entirely. This caused it to "forget" all previous subscriptions, allowing me to re-subscribe only to the specific datapoints/tags I actually wanted to monitor — excluding the ones I was trying to remove.

This is the reason why automating the redeploy via flow injection was so helpful in the first place.

Thanks again for the quick response — really appreciate it!

I am not sure it is permitted to change the subscriptions (dynamically).
Not my area.

Indulge me....

Why are you needing to change the subscriptions?

I would have thought they would be fixed.

I hope someone can help you though.

From what I was told, having the ability to dynamically manage OPC UA subscriptions is actually important for a few key reasons:

  1. Project expansion – As new tags are added to the system, it should be easy to include them without having to manually rebuild or redeploy everything.
  2. Maintenance and fault recovery – If a tag stops working or needs to be replaced, it should be possible to swap it out without restarting the whole setup.
  3. Decommissioning old infrastructure – When certain equipment or tags are no longer needed, it should be possible to cleanly remove them to avoid unnecessary clutter and processing.

Based on this, I was tasked with finding a Node-RED-based solution that could automatically manage subscriptions and store the resulting data in a SQL database.

The goal is to let someone manage the list of tags directly from the database — adding, modifying, or removing them — and have Node-RED handle the subscription changes accordingly.

So far:

  • Adding and subscribing to new tags works perfectly.
  • The problem arises when trying to remove or modify tags, since that requires unsubscribing first — and that part only worked before I enabled authentication.

So now I’m trying to get that dynamic unsubscription/redeployment working again, but in an authenticated Node-RED environment.

The API Docs includes a section on how to use it if authentication is enabled.