mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add support for httpStaticCors
This commit is contained in:
parent
10398b05d8
commit
48a2876c48
1
packages/node_modules/node-red/package.json
vendored
1
packages/node_modules/node-red/package.json
vendored
@ -37,6 +37,7 @@
|
|||||||
"@node-red/nodes": "4.0.0-beta.4",
|
"@node-red/nodes": "4.0.0-beta.4",
|
||||||
"basic-auth": "2.0.1",
|
"basic-auth": "2.0.1",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
|
"cors": "2.8.5",
|
||||||
"express": "4.19.2",
|
"express": "4.19.2",
|
||||||
"fs-extra": "11.2.0",
|
"fs-extra": "11.2.0",
|
||||||
"node-red-admin": "^3.1.3",
|
"node-red-admin": "^3.1.3",
|
||||||
|
8
packages/node_modules/node-red/red.js
vendored
8
packages/node_modules/node-red/red.js
vendored
@ -44,6 +44,8 @@ var nopt = require("nopt");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
const os = require("os")
|
const os = require("os")
|
||||||
var fs = require("fs-extra");
|
var fs = require("fs-extra");
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
var RED = require("./lib/red.js");
|
var RED = require("./lib/red.js");
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
@ -441,10 +443,16 @@ httpsPromise.then(function(startupHttps) {
|
|||||||
const thisRoot = sp.root || "/";
|
const thisRoot = sp.root || "/";
|
||||||
const options = sp.options;
|
const options = sp.options;
|
||||||
const middleware = sp.middleware;
|
const middleware = sp.middleware;
|
||||||
|
const corsOptions = sp.cors || settings.httpStaticCors;
|
||||||
if(appUseMem[filePath + "::" + thisRoot]) {
|
if(appUseMem[filePath + "::" + thisRoot]) {
|
||||||
continue;// this path and root already registered!
|
continue;// this path and root already registered!
|
||||||
}
|
}
|
||||||
appUseMem[filePath + "::" + thisRoot] = true;
|
appUseMem[filePath + "::" + thisRoot] = true;
|
||||||
|
if (corsOptions) {
|
||||||
|
const corsHandler = cors(corsOptions);
|
||||||
|
app.options(thisRoot, corsHandler)
|
||||||
|
app.use(thisRoot, corsHandler)
|
||||||
|
}
|
||||||
if (settings.httpStaticAuth) {
|
if (settings.httpStaticAuth) {
|
||||||
app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass));
|
app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user