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 util = require("util");
|
||||
var express = require("express");
|
||||
var crypto = require("crypto");
|
||||
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 app = express();
|
||||
|
||||
settings.httpRoot = settings.httpRoot||"";
|
||||
if (settings.httpRoot.slice(-1) == "/") {
|
||||
settings.httpRoot = settings.httpRoot.slice(0,-1);
|
||||
var redApp = null;
|
||||
|
||||
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] != "/") {
|
||||
settings.httpRoot = "/"+settings.httpRoot;
|
||||
}
|
||||
if (settings.httpRoot == "/") {
|
||||
settings.httpRoot = "";
|
||||
if (settings.httpRoot.slice(-1) != "/") {
|
||||
settings.httpRoot = settings.httpRoot + "/";
|
||||
}
|
||||
settings.uiPort = settings.uiPort||1880;
|
||||
|
||||
|
||||
if (settings.httpAuth) {
|
||||
app.use(settings.httpRoot,
|
||||
express.basicAuth(function(user, pass) {
|
||||
|
10
red/ui.js
10
red/ui.js
@ -21,8 +21,14 @@ var app = express();
|
||||
|
||||
function setupUI(settings) {
|
||||
|
||||
app.get(/^$/,function(req,res) {
|
||||
res.redirect("/");
|
||||
// Need to ensure the url ends with a '/' so the static serving works
|
||||
// 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'));
|
||||
|
Loading…
Reference in New Issue
Block a user