Skip to content

[site] Fix CSP violations on the 404 page - #877

Open
the-other-tim-brown wants to merge 1 commit into
apache:mainfrom
the-other-tim-brown:csp-fix-404-page
Open

[site] Fix CSP violations on the 404 page#877
the-other-tim-brown wants to merge 1 commit into
apache:mainfrom
the-other-tim-brown:csp-fix-404-page

Conversation

@the-other-tim-brown

Copy link
Copy Markdown
Contributor

What

The 404 page loads three third-party resources that the ASF Content-Security-Policy blocks. In production it renders with a broken illustration placeholder and console errors.

Resource Line Purpose
ajax.googleapis.com/.../webfont.js + WebFont.load(...) 16-17 Material Icons loader
fonts.googleapis.com / fonts.gstatic.com preconnects 14-15 for the above
d3e54v103j8qbb.cloudfront.net/static/page-not-found...svg 24 "page not found" illustration
d3e54v103j8qbb.cloudfront.net/js/jquery-3.5.1.min...js 29 jQuery

Why it came back

#764 removed exactly these from the home page, but it did so by deleting static/404.html outright. #863 then reintroduced the page at homepage/404.html from the pre-#764 Webflow export, which brought the CDN references back with it.

Changes

Same treatment #764 gave the home page:

  • Font loader — deleted. The 404 page has no Material Icons ligatures on it at all (no FAQ accordions), so it was dead weight even before CSP.
  • jQuery — repointed at js/jquery-3.5.1.min.js, the copy [site] Fix CSP issues on the website #764 already vendored into static/js/.
  • Illustration — vendored the 754-byte SVG to static/images/page-not-found.svg. Keeping it as a file rather than inlining it means no layout change, no new CSS, and no inline style attribute. RAT excludes **/website/** and Github.svg / linkedin.svg / twitter.svg already ship without headers, so this matches existing practice.

The page now loads entirely from the site's own origin — the only remaining http string in the file is the Webflow attribution comment on line 1.

Testing

npm run build && npm run serve, then requested a nonexistent path:

  • the Webflow "Page Not Found" page renders, now referencing page-not-found.svg with no cloudfront references in the output
  • every asset the page references resolves locally: css/normalize.css, css/webflow.css, css/onetable-ad267e.webflow.css, images/xtable-favicon.png, images/page-not-found.svg, js/jquery-3.5.1.min.js, js/webflow.js
  • home page output unchanged

Note, not fixed here

Both homepage/404.html:16 and homepage/index.html:23 reference images/webclip.png as their apple-touch-icon, but that file was deleted in 62ca0c0 ("removed unused images"). It 404s on both pages. Not a CSP issue and it affects the home page equally, so it seemed better left to its own change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CyVF3fyK2VQE7DPd31mRLv

The 404 page still loads three third-party resources that the ASF
Content-Security-Policy blocks, so in production it renders with a
broken illustration and console errors:

  - ajax.googleapis.com WebFont loader (plus the fonts.googleapis.com /
    fonts.gstatic.com preconnects) — the page has no Material Icons
    ligatures on it at all, so this is dead weight regardless
  - d3e54v103j8qbb.cloudfront.net for the "page not found" illustration
  - d3e54v103j8qbb.cloudfront.net for jQuery

apache#764 removed exactly these from the home page, but it did so by deleting
static/404.html outright. apache#863 then reintroduced the page at
homepage/404.html from the pre-apache#764 Webflow export, which brought the
CDN references back with it.

Apply the same treatment apache#764 gave the home page: drop the font loader,
point jQuery at the copy already vendored in static/js/, and vendor the
754-byte illustration into static/images/. The page now loads entirely
from the site's own origin.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CyVF3fyK2VQE7DPd31mRLv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant