Summary
The frontend is currently exposed to two critical risks: Cross-Site Scripting (XSS) vulnerabilities due to the absence of Content Security Policy (CSP) headers, and total application crashes (white screens of death) due to unhandled React exceptions.
We must harden the application. First, configure strict CSP headers in next.config.js to rigidly define script-src and connect-src, preventing any malicious script execution. Second, a global React ErrorBoundary must be wrapped around the component tree. This boundary must catch runtime exceptions, log them to our telemetry service, and present a graceful recovery UI to the merchant rather than a blank screen.
Acceptance Criteria
Tech Stack
Next.js 14, React.
Summary
The frontend is currently exposed to two critical risks: Cross-Site Scripting (XSS) vulnerabilities due to the absence of Content Security Policy (CSP) headers, and total application crashes (white screens of death) due to unhandled React exceptions.
We must harden the application. First, configure strict CSP headers in
next.config.jsto rigidly definescript-srcandconnect-src, preventing any malicious script execution. Second, a global ReactErrorBoundarymust be wrapped around the component tree. This boundary must catch runtime exceptions, log them to our telemetry service, and present a graceful recovery UI to the merchant rather than a blank screen.Acceptance Criteria
next.config.js.ErrorBoundarycomponent with a clean fallback UI.Tech Stack
Next.js 14, React.