Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Core delivery platform Node.js Frontend Template.
- [Requirements](#requirements)
- [Node.js](#nodejs)
- [DXT Forms Engine Plugin](#dxt-forms-engine-plugin)
- [Static File Routes & Accessibility Scanner Support](#static-file-routes--accessibility-scanner-support)
- [Features](#features)
- [Development Tools & Configuration](#development-tools--configuration)
- [Testing Framework](#testing-framework)
Expand Down Expand Up @@ -144,6 +145,24 @@ sequenceDiagram
Ctrl-->>User: Redirect to confirmation
```

## Static File Routes & Accessibility Scanner Support

The CDP dev environment runs automated accessibility testing using HeadlessChrome. This scanner attempts to load icon resources (e.g., `aria.svg`, `header.svg`, `h1.svg`, etc.) to visualise accessibility features on the page. These icons are not part of the application itself but are used by the scanner's visualisation overlay.

To prevent 400 errors in logs from these scanner requests, a catch-all route was added in `src/server/common/helpers/serve-static-files.js` that:

- Intercepts all `/img/{param*}` requests
- Returns a valid empty SVG with 200 OK status
- Satisfies the accessibility scanner without cluttering logs with errors

This ensures clean logs while maintaining compatibility with CDP platform accessibility monitoring tools.

Test locally with:

```bash
curl -v http://localhost:3000/img/icons/aria.svg`
```

## Development Tools & Configuration

### Testing Framework
Expand Down
39 changes: 3 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"author": "Defra DDTS",
"license": "OGL-UK-3.0",
"overrides": {
"tmp": "0.2.4"
"tmp": "0.2.4",
"node-forge": "1.3.2"
},
"dependencies": {
"@babel/runtime": "7.28.4",
Expand Down
9 changes: 9 additions & 0 deletions src/server/common/helpers/serve-static-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export const serveStaticFiles = {
},
options
},
{
method: 'GET',
path: '/img/{param*}',
handler(_request, h) {
const emptySvg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"></svg>'
return h.response(emptySvg).code(statusCodes.ok).type('image/svg+xml')
},
options
},
{
method: 'GET',
path: `${config.get('assetPath')}/{param*}`,
Expand Down
Loading
Loading