Repository navigation
Lighthouse fixes: coin photos as WebP/AVIF, no 401 console error, CSP cleanups - #242
Merged
Merged
Conversation
From a Lighthouse run on a deploy preview: - Coin photos (Gravatar 234 KiB, GitHub avatar) were full-size PNG/JPEG. On Netlify they now go through its Image CDN: resized to the coin (240/480/720w srcset) and sent as WebP or AVIF. netlify.toml [images] allows only those two exact images, with a test that it isn't an open proxy. Local builds keep the direct links. - /api/me answered 401 to every signed-out visitor, logged as a console error on every page. With no session cookie at all it's now a 204; a bad cookie is still 401, a non-owner 403. - The report-only CSP on deploy previews no longer includes upgrade-insecure-requests (ignored there, with a warning per page). - Simple Analytics, added by the site's Netlify settings, was blocked by the enforced CSP. Its script host and report queue are allowed, and nothing broader (tested). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nginuw5wmUjUSkmQB1J3pS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nginuw5wmUjUSkmQB1J3pS
github-actions
Bot
force-pushed
the
lighthouse
branch
from
October 24, 2026 21:02
de8b557 to
4746081
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the issues from a Lighthouse run on a deploy preview:
/api/meanswered401to every signed-out visitor on every page.upgrade-insecure-requestsis ignored when delivered in a report-only policy", three times per page on previews.scripts.simpleanalyticscdn.com/latest.jsandauto-events.js) was blocked. It's added by the site's Netlify settings, so on the live site, where the CSP is enforced, it never ran.Builds on #241 (the Nuxt 4 fix that main needs before anything deploys). Merge #241 first; this PR's diff then shrinks to its own changes.
Related Issue
None. The user shared the Lighthouse report and asked for fixes.
Changes Made
utils/coinFaces.mjs,components/Bitmoji.vue,nuxt.config.js,netlify.toml):NETLIFY=true, exposed asruntimeConfig.public.imageCdn), the photos go through Netlify's Image CDN:/.netlify/images?url=…&w=….srcsetof 240/480/720w andsizesmatching the coin (170–230px). The CDN sends WebP or AVIF to browsers that accept them.netlify.toml[images] remote_imagesallows only those two exact images, so the CDN can't be used as an open image proxy for hanselwei.dev./api/me(netlify/functions/me.mjs):204 No Content. That isn't an error, so nothing is logged.401.403. Owner:200.scripts/lib/csp.mjs,scripts/build-csp.mjs):upgrade-insecure-requests. Production still enforces it.script-srcallowshttps://scripts.simpleanalyticscdn.com, andconnect-srcallowshttps://queue.simpleanalyticscdn.com. Nothing broader is allowed.tests/security/headers.test.mjs:http:andjavascript:are all refused.upgrade-insecure-requests.tests/security/auth-routes.test.mjs: no cookie, or an empty or unrelated cookie, gets 204; a forged cookie still gets 401.tests/app/coin-photos.test.mjs: thesrcsetandsizes; the source URL stays a single query value; sources are big enough.README.md: the coin photos line.How to Test
npm test: 226 pass.NETLIFY=true CONTEXT=deploy-preview npm run generate./.netlify/images?url=…&w=240|480|720._headershasContent-Security-Policy-Report-Onlywithoutupgrade-insecure-requests, and with the Simple Analytics origins.npm run generate. The photos load straight from GitHub and Gravatar, and the enforced CSP keepsupgrade-insecure-requests.Additional Notes
Generated by Claude Code