fix(cropper): make load failures visible; loud config errors
'Load next queued' did nothing because the running server had been started without its env file (a restart used '-f .env' from tools/, where no .env exists), so the cropper was unconfigured and every action answered 503 — and none of that was visible, because notifications never rendered either: - notifications used cds-toast/cds-toast-item, which the Carbon bundle does not define; a cds-toast-notification element renders nothing standalone in this build. The cropper now uses cds-inline-notification in the fixed toast viewport (renders, themed, close button) like the wizard - an unconfigured deployment now says so on the page (503 'Cropper unavailable') instead of rendering actions that all fail, and logs a startup warning naming the missing credentials - tests: notifications use a registered element; unconfigured page 503
This commit is contained in:
+15
-1
@@ -12,7 +12,7 @@ import fs from 'node:fs';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import { loadYrkaSession, extractPbCookieValue } from './yrka-auth.js';
|
||||
import { permittedDomains, stripPhonePrefix, CACHE_FRESH, DOMAIN_TTL_MS, cropPermission } from './permit.js';
|
||||
import { createCropperRouter, buildCropperClients } from './cropper.js';
|
||||
import { createCropperRouter, buildCropperClients, CROPPER_CREDENTIALS } from './cropper.js';
|
||||
|
||||
// ── Hardcoded configuration ──────────────────────────────────────────────────
|
||||
export const PORT = 4173;
|
||||
@@ -471,6 +471,14 @@ export function createApp(overrides = {}) {
|
||||
next();
|
||||
};
|
||||
app.get('/cropper', requirePage, pageCropGate, (req, res, next) => {
|
||||
if (!cropperClients) {
|
||||
return errorPage(
|
||||
res,
|
||||
503,
|
||||
'Cropper unavailable',
|
||||
'The image cropper is not configured on this deployment. Contact your administrator.'
|
||||
);
|
||||
}
|
||||
renderPage(
|
||||
res,
|
||||
'cropper/index.html',
|
||||
@@ -479,6 +487,12 @@ export function createApp(overrides = {}) {
|
||||
);
|
||||
});
|
||||
const cropperClients = cfg.cropperClients !== undefined ? cfg.cropperClients : buildCropperClients();
|
||||
if (!cropperClients) {
|
||||
const missing = CROPPER_CREDENTIALS.filter((name) => !process.env[name]);
|
||||
console.warn(
|
||||
`[cropper] not configured — missing ${missing.join(', ')}; /cropper will answer 503`
|
||||
);
|
||||
}
|
||||
if (cropperClients) {
|
||||
app.use(
|
||||
'/cropper',
|
||||
|
||||
Reference in New Issue
Block a user