From 1fd69fcaa5c2ae1f958fd48832b05a4579ec0af2 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Fri, 10 Apr 2020 09:43:37 +0200 Subject: [PATCH] bugfix: render index --- deploy/app.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/deploy/app.js b/deploy/app.js index ebbea597d..00c8529f2 100644 --- a/deploy/app.js +++ b/deploy/app.js @@ -90,13 +90,21 @@ const indexTemplate = require('fs').readFileSync( ) app.get('/', cookieParser(), (req, res) => { const iavError = req.cookies && req.cookies['iav-error'] - if (iavError) res.clearCookie('iav-error', { httpOnly: true, sameSite: 'strict' }) res.setHeader('Content-Type', 'text/html') - const returnTemplate = indexTemplate - .replace(/\$\$NONCE\$\$/g, res.locals.nonce) - .replace('<atlas-viewer>', `<atlas-viewer data-error="${iavError.replace(/"/g, '"')}">`) - res.status(200).send(returnTemplate) + + if (iavError) { + res.clearCookie('iav-error', { httpOnly: true, sameSite: 'strict' }) + + const returnTemplate = indexTemplate + .replace(/\$\$NONCE\$\$/g, res.locals.nonce) + .replace('<atlas-viewer>', `<atlas-viewer data-error="${iavError.replace(/"/g, '"')}">`) + res.status(200).send(returnTemplate) + } else { + const returnTemplate = indexTemplate + .replace(/\$\$NONCE\$\$/g, res.locals.nonce) + res.status(200).send(returnTemplate) + } }) /** -- GitLab