Repository navigation
Fix cameras not loading: serve the camera catalogue uncompressed and let Next.js compress it - #518
Merged
Merged
Conversation
…mpress it Next.js 16.4.5 drops a route handler's own Content-Encoding header, and 16.4.6 compresses route responses automatically. The catalogue was pre-gzipped, so browsers received it gzipped twice, could not parse it, and no cameras loaded. /api/stats reads /api/cctv internally and failed the same way, leaving every counter at 0. Serve the serialised JSON and leave compression to Next.js. The payload no longer carries a gzip copy, which also removes a synchronous gzip of the whole catalogue from every rebuild.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
Since the update to Next.js 16.4.6 (#516), no cameras load on the map, and the stats counters show 0.
/api/cctvserved a pre-gzipped catalogue withContent-Encoding: gzip.Content-Encodingheader (part of its security fixes)./api/statsreads/api/cctvinternally and fails the same way, so every counter stays at 0.Rolling Next.js back to 16.4.5 does not fix this, because that version already drops the header. Rolling back to 16.4.3 would reopen the seven advisories fixed in 16.4.5. This change keeps 16.4.6 and fixes the route instead.
Changes
servePayloadinsrc/app/api/cctv/route.tsalways sends the serialised JSON. Next.js compresses it once for clients that accept gzip. ETag and 304 handling are unchanged.src/lib/cctv-snapshot.ts: the payload no longer keeps a gzip copy. This also removes a synchronous gzip of the whole catalogue from every rebuild.Content-Encoding. The snapshot test drops its gzip assertions.Testing
vitest: camera route, snapshot and stats tests pass (25).tsc --noEmitpasses./api/cctvrequested withAccept-Encoding: gzipcomes back gzipped once and parses as JSON.If-None-Match(304) still work./api/statsreturns non-zero counts again.🤖 Generated with SIMPLIFAI