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 ?