Cancel
Showing results for 
Search instead for 
Did you mean: 

deploy node-red as a mindapp

Creator
Creator

Hi,

 

I'm aware that mindsphere visual flow creator is the node-red flavour available as an addon. at the moment visual flow creator is not an option for us, hence we are looking to deploy vanila node-red as a mindapp.

 

I have done followings;

1. deploy vanila node -red as mindapp

2. made few changes to retrieve XSRF-TOKEN and set as a request header in red.js. seems this change doesn't pick.

3. so, i edited httpServerOptions in settings.js as follows; (i'll replace with proper token)

    httpServerOptions: (app) => {
        
        app.use(function (req, res, next) {
            console.log('=========================== Time: %d', Date.now());
            next();
        });
    },

When i deploy a sample flow, it doesn't print the log message - that i introduced. 

 

Did anyone resolve this type of issue?

8 REPLIES 8

Re: deploy node-red as a mindapp

Siemens Genius Siemens Genius
Siemens Genius

Are you able to deploy the flow as a MindAPP? Looking at the node-red  github issues page, the developer of node-red has commented that they don't have a csrf handling in Node-RED. You can give this a try and see if this fixes your problem. 

Re: deploy node-red as a mindapp

Legend
Legend
In case the authentication headers are the issue, you might also be able to use an approach similar to the devopsadmin component in devops-demo:

- deploy node-red as a cloudfoundry app not exposed to the outside
- deploy an extra app exposing endpoints that proxy requests to the internal node-red component, adapting the authentication headers as needed

https://gitlab.com/mindsphere/devops-demo/tree/master/devops

If you explore this and you make it work, I'd be glad to hear back in this thread about it :-)

Re: deploy node-red as a mindapp

Valued Contributor
Valued Contributor

@dlouzan I actually had a proxy app which was fairly generic and which was adapting the authentication as needed. However there were some issues with how mindgate was treating some query string parameters (and it was breaking e.g. rabbitmq ui) so that I just gave up at some point....maybe worth revisiting once the issue has been fixed.

Re: deploy node-red as a mindapp

Creator
Creator

@SriramSivakumar ,

 

thanks for your feedback. unfortunately the suggested approached didn't work for me. so, i tried @dlouzan  approach.

Re: deploy node-red as a mindapp

Creator
Creator

@dlouzan ,

 

Thanks for your feedback. 

 

i went through devopsadmin and tried similar approach to send X-XSRF-TOKEN as a header to Node-RED. it's doesn't pick the value. Smiley Sad

 

i tried following approaches;

  1. wrote a middleware in red.js (node red sources) to add the token. (i modified serveral places in the code - no luck)
  2. nodered embedded to an exsiting app - which set the token as header.
  3. after the deployment - modified node-red sources (inside cloud foundry app). buildpack overwritten these changes during restart/restage

 

according to my current understanding node-red doesn't cater for custom middlewares. i raised this in nodered community. 

Re: deploy node-red as a mindapp

Legend
Legend

after the deployment - modified node-red sources (inside cloud foundry app). buildpack overwritten these changes during restart/rest

That is to be expected. If you want to modify the sources, you'd have to modify them on your checked out local version, and then push a manifest the uses the local contents.

 

It's basically what we do with grafana and prometheus in devops-demo; in that case they are Golang buildpacks, but the idea is the same.

Re: deploy node-red as a mindapp

Creator
Creator

@dlouzan ,

 

as mentioned in my 1st point i have done what you have said.

i have extracted node-red directory & modified  the code to include the token in serveral places (including runtime, httpAdmin apps, etc..). the token is setted as request.header['x-xsrf-token']. then it's push to mindsphere cloudfoundry. 

when i try to deploy a sample flow, it gives following error message

Invalid CSRF Token "null" was found on the request parameter '_csrf" or header 'X-XSRF-TOKEN'

 

It means the changes were not picked by node-red. however, i could see the token printed in the console. 

 

any success deployment node-red as mindapp?

 

Note: I must thank you and the team for putting a great effort for the demo app. 

 

Re: deploy node-red as a mindapp

Legend
Legend
Sorry, I must have missed that in the original question. I don't know what exactly you're doing wrong, since we have no experience deploying node-red.