Repository navigation
fix(visitors): hide footer stats when Upstash isn't configured - #425
Merged
anurag629 merged 1 commit intoNov 18, 2026
Merged
Conversation
Without UPSTASH_REDIS_REST_URL/TOKEN the API 500'd and the footer showed a broken Stats block on every page. The route now answers 204 for GET and POST when either secret is missing, and the footer hides the Stats block on any non-200 response, remembering it across client-side navigations. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
anurag629
approved these changes
Nov 17, 2026
Member
|
Hey @Seyamalam, thanks again for this one! If you haven't yet, come join our Discord (https://discord.gg/mpGdJyjaRQ) and run |
4 tasks
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.
Description
OGCOPS "requires no environment variables for basic usage", but without
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENthe footer still rendered a Stats block stuck on placeholder dashes, and every page load logged a failed/api/visitors500 in the console — for every contributor runningnpm run devand for visitors of any self-hosted copy without the counter./api/visitorsnow answers204 No Contentto GET and POST when either secret is missing, without calling Upstash; a real Upstash failure with the secrets set still returns 500. The footer script checksr.statusbeforer.json()— on any non-200 it hides the Stats title and counter row while keeping the MIT License / copyright line, and remembers that result so footers swapped in on client-side navigations are hidden the same way.Closes #420
How I Tested This
npx vitest run tests/api/visitors.test.ts— 10 new tests: GET and POST return 204 with nofetchcall when neither or only one secret is set; with both set, GET/POST return the counts, and a real Upstash failure still returns 500.astro:env/serveris mocked the waytests/middleware.test.tsmocksastro:middleware, andfetchis stubbed.src/pages/api/visitors.ts, reran the file — the 204 cases returned the old 500; then restored the fix.npm run devwith no.env:curl -i http://localhost:4321/api/visitors→204 No Content;curl -i -X POST -H 'Content-Type: application/json' -H 'Origin: http://localhost:4321' http://localhost:4321/api/visitors→204 No Content; footer shows no Stats block and no console 500 (screenshot below).npm run check,npm run test(2120 tests), andnpm run buildall pass.AI Assistance
Devin CLI (SWE-2 High): implemented the route guard, the footer script change, and the new test file under human direction; the diff was reviewed and verified by the operator before filing.
Type of Change
Screenshots
Checklist
devnpm run checkpassesnpm run testpassesnpm run devCreated with SWE-2 High in Devin CLI.