Node-RED Get /red/comms 404 and 301

299 views
Skip to first unread message

rom

unread,
Dec 12, 2016, 12:37:01 PM12/12/16
to Node-RED
Hi guys,

I was trying to embed Node-RED into an express app, and I think I followed the example closely:

var app = express();
...
var server = app.listen(PORT, function() {
//some printing
});

var settings = {
    httpAdminRoot:"/red",
    httpNodeRoot: "/api",
    userDir:"./.nodered/",
    functionGlobalContext: { }
};

RED.init(server,settings);
app.use(settings.httpAdminRoot,RED.httpAdmin);
app.use(settings.httpNodeRoot,RED.httpNode);
//app.use("/red/*",RED.httpAdmin); 
RED.start();
When I put the above code (with the second last line commented out) in AWS and access Node-RED UI from my own computer, I saw "GET /red/comms 404" on the server side.
If I uncomment that line, then I got "GET /red/comms 301". In the second case, the debug output in the UI doesn't work either.

I have got two questions:
1. why I saw 404 while commenting out the line app.use("/red/*",RED.httpAdmin)? Wouldn't app.use(settings.httpAdminRoot,RED.httpAdmin) cover all the cases in  app.use("/red/*",RED.httpAdmin)? According to this post: "app.use only see whether url starts with specified path". Since settings.httpAdminRoot is "/red", why I still need "/red/*"?
2. How can I resolve this 301 issue ?

Julian Knight

unread,
Dec 12, 2016, 3:58:39 PM12/12/16
to Node-RED
Don't know the answer but you might find this helpful? https://github.com/TotallyInformation/node-red-template-embedded
Reply all
Reply to author
Forward
0 new messages