diff --git a/CHANGELOG.md b/CHANGELOG.md index 240dfca..dcd14bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.18.0 +- feat: Add SSO-style error page (404/500) for browser navigation instead of a bare text response +- feat: navbar — username no longer underlined; only the active link is bold + underlined + ## v1.16.1 - fix: remove missing DEPLOYMENT.md from Docker build context diff --git a/nodejs/app.js b/nodejs/app.js index eb7d128..fe081f8 100644 --- a/nodejs/app.js +++ b/nodejs/app.js @@ -4,6 +4,8 @@ const express = require('express'); const compression = require('compression'); require('./models'); // wire model-redis + register models +const conf = require('@simpleworkjs/conf'); +const buildInfo = require('./utils/build_info'); const app = express(); @@ -41,7 +43,15 @@ app.use((err, req, res, next) => { if(req.path.startsWith('/api/')){ return res.status(status).json({name: err.name || 'Error', message: err.message || 'Error'}); } - res.status(status).send(err.message || 'Error'); + // Browser navigation gets the HTML error page (shared with SSO). + res.status(status).render('error', { + title: conf.environment !== 'production' ? 'dev' : '', + titleIcon: conf.environment !== 'production' ? '' : '', + name: conf.name, + logo: conf.logo, + ...buildInfo, + error: err, + }); }); module.exports = app; diff --git a/nodejs/public/css/styles.css b/nodejs/public/css/styles.css index 7065eae..fd0dde2 100755 --- a/nodejs/public/css/styles.css +++ b/nodejs/public/css/styles.css @@ -3,6 +3,12 @@ nav.navbar{ padding-right: 1em; } +/* Only the active top-nav link is bold + underlined; the username is plain. */ +.top-nav a.active{ + font-weight: bold; + text-decoration: underline; +} + body { display: flex; flex-direction: column; diff --git a/nodejs/views/error.ejs b/nodejs/views/error.ejs new file mode 100644 index 0000000..03fdca4 --- /dev/null +++ b/nodejs/views/error.ejs @@ -0,0 +1,25 @@ +<%- include('top') %> + +
+ <% if (error.status === 404) { %> + The page you are looking for doesn't exist or has been moved. + <% } else { %> + An unexpected error occurred. Please try again later. + <% } %> +
+ + Return to Home + +