Restore caching busting functionality without using explict version number

Fixes #4503
This commit is contained in:
Nick O'Leary
2024-01-05 23:13:30 +00:00
parent f0a9b0cf69
commit d7345d5bc6
2 changed files with 12 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
const crypto = require('crypto')
var express = require('express');
var fs = require("fs");
var path = require("path");
@@ -28,6 +29,8 @@ var editorClientDir = path.dirname(require.resolve("@node-red/editor-client"));
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.svg");
var editorTemplatePath = path.join(editorClientDir,"templates","index.mst");
var editorTemplate;
const version = require(path.join(editorClientDir,"package.json")).version
const cacheBuster = crypto.createHash('md5').update(version).digest("hex").substring(0,12)
module.exports = {
init: function(_runtimeAPI) {
@@ -99,6 +102,7 @@ module.exports = {
}
res.send(Mustache.render(editorTemplate,{
sessionMessages,
cacheBuster,
...await theme.context()
}));
},