diff --git a/package-lock.json b/package-lock.json index eac72a7c5..67b44cbf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "express": "^4.18.2", "express-async-handler": "^1.2.0", "express-static-gzip": "2.1.7", + "fs": "^0.0.1-security", "fs-extra": "11.1.1", "js-yaml": "^4.1.0", "jwt-simple": "^0.5.6", @@ -6466,6 +6467,11 @@ "node": ">= 0.6" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "node_modules/fs-extra": { "version": "11.1.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", diff --git a/package.json b/package.json index 08992aff4..5e5d263eb 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Create authentic looking D&D homebrews using only markdown", "version": "3.10.0", "engines": { - "npm": "^10.2.x", + "npm": "^10.2.x", "node": ">=20.8.x" }, "repository": { @@ -93,6 +93,7 @@ "express": "^4.18.2", "express-async-handler": "^1.2.0", "express-static-gzip": "2.1.7", + "fs": "^0.0.1-security", "fs-extra": "11.1.1", "js-yaml": "^4.1.0", "jwt-simple": "^0.5.6", diff --git a/server/app.js b/server/app.js index a19030b3a..9ef4518bc 100644 --- a/server/app.js +++ b/server/app.js @@ -8,6 +8,7 @@ const express = require('express'); const yaml = require('js-yaml'); const app = express(); const config = require('./config.js'); +const fs = require('fs'); const { homebrewApi, getBrew } = require('./homebrew.api.js'); const GoogleActions = require('./googleActions.js'); @@ -416,6 +417,9 @@ if(isLocalEnvironment){ const payload = jwt.encode({ username: username, issued: new Date }, config.get('secret')); return res.json(payload); }); + // Add Static Local Paths + app.use('/staticImages', express.static(config.get('hb_images') && fs.existsSync(config.get('hb_images')) ? config.get('hb_images') :'staticImages')); + app.use(express.static(config.get('hb_fonts') && fs.existsSync(config.get('hb_fonts')) ? config.get('hb_fonts'):'staticFonts')); } //Render the page