mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'master' of github.com:node-red/node-red
This commit is contained in:
commit
77eb0f76ce
30
red.js
30
red.js
@ -17,34 +17,32 @@ var http = require('http');
|
|||||||
var https = require('https');
|
var https = require('https');
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
var express = require("express");
|
var express = require("express");
|
||||||
|
var crypto = require("crypto");
|
||||||
var settings = require("./settings");
|
var settings = require("./settings");
|
||||||
|
|
||||||
var redApp = null;
|
|
||||||
|
|
||||||
if (settings.https) {
|
|
||||||
server = https.createServer(settings.https,function(req,res){redApp(req,res);});
|
|
||||||
} else {
|
|
||||||
server = http.createServer(function(req,res){redApp(req,res);});
|
|
||||||
}
|
|
||||||
|
|
||||||
redApp = require('./red/server.js').init(server,settings);
|
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
settings.httpRoot = settings.httpRoot||"";
|
var redApp = null;
|
||||||
if (settings.httpRoot.slice(-1) == "/") {
|
|
||||||
settings.httpRoot = settings.httpRoot.slice(0,-1);
|
if (settings.https) {
|
||||||
|
server = https.createServer(settings.https,function(req,res){app(req,res);});
|
||||||
|
} else {
|
||||||
|
server = http.createServer(function(req,res){app(req,res);});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redApp = require('./red/server.js').init(server,settings);
|
||||||
|
|
||||||
|
settings.httpRoot = settings.httpRoot||"/";
|
||||||
|
|
||||||
if (settings.httpRoot[0] != "/") {
|
if (settings.httpRoot[0] != "/") {
|
||||||
settings.httpRoot = "/"+settings.httpRoot;
|
settings.httpRoot = "/"+settings.httpRoot;
|
||||||
}
|
}
|
||||||
if (settings.httpRoot == "/") {
|
if (settings.httpRoot.slice(-1) != "/") {
|
||||||
settings.httpRoot = "";
|
settings.httpRoot = settings.httpRoot + "/";
|
||||||
}
|
}
|
||||||
settings.uiPort = settings.uiPort||1880;
|
settings.uiPort = settings.uiPort||1880;
|
||||||
|
|
||||||
|
|
||||||
if (settings.httpAuth) {
|
if (settings.httpAuth) {
|
||||||
app.use(settings.httpRoot,
|
app.use(settings.httpRoot,
|
||||||
express.basicAuth(function(user, pass) {
|
express.basicAuth(function(user, pass) {
|
||||||
|
10
red/ui.js
10
red/ui.js
@ -21,8 +21,14 @@ var app = express();
|
|||||||
|
|
||||||
function setupUI(settings) {
|
function setupUI(settings) {
|
||||||
|
|
||||||
app.get(/^$/,function(req,res) {
|
// Need to ensure the url ends with a '/' so the static serving works
|
||||||
res.redirect("/");
|
// with relative paths
|
||||||
|
app.get("/",function(req,res) {
|
||||||
|
if (req.originalUrl.slice(-1) != "/") {
|
||||||
|
res.redirect(req.originalUrl+"/");
|
||||||
|
} else {
|
||||||
|
req.next();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use("/",express.static(__dirname + '/../public'));
|
app.use("/",express.static(__dirname + '/../public'));
|
||||||
|
Loading…
Reference in New Issue
Block a user