diff --git a/public/src/app.js b/public/src/app.js index a20aaf0bde..68cfd9024f 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -353,7 +353,7 @@ app.flags = {}; function registerServiceWorker() { // Do not register for Safari browsers - if (!ajaxify.data._locals.useragent.isSafari && 'serviceWorker' in navigator) { + if (!config.useragent.isSafari && 'serviceWorker' in navigator) { navigator.serviceWorker.register(config.relative_path + '/service-worker.js', { scope: config.relative_path + '/' }) .then(function () { console.info('ServiceWorker registration succeeded.'); diff --git a/src/controllers/api.js b/src/controllers/api.js index 984ea98e42..1194a75399 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -81,6 +81,7 @@ apiController.loadConfig = async function (req) { }, iconBackgrounds: await user.getIconBackgrounds(req.uid), emailPrompt: meta.config.emailPrompt, + useragent: req.useragent, }; let settings = config; diff --git a/src/middleware/render.js b/src/middleware/render.js index 6957f5a6d2..8555ee9314 100644 --- a/src/middleware/render.js +++ b/src/middleware/render.js @@ -65,7 +65,7 @@ module.exports = function (middleware) { req.app.set('json spaces', global.env === 'development' || req.query.pretty ? 4 : 0); return res.json(options); } - + const optionsString = JSON.stringify(options).replace(/<\//g, '<\\/'); const results = await utils.promiseParallel({ header: renderHeaderFooter('renderHeader', req, res, options), content: renderContent(render, templateToRender, req, res, options), @@ -76,7 +76,7 @@ module.exports = function (middleware) { (res.locals.postHeader || '') + results.content }${ res.locals.preFooter || '' }${results.footer}`;