fix: 404 status on catch-all routes and admin gate on AI content API #157
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
javascript
question
severity: high
severity: low
severity: medium
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
isyuricunha/website!157
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/audit-soft-404-and-ai-content-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Full-project audit findings: two confirmed behavior bugs fixed, one low-severity API normalization fixed, each with a regression test.
Evidence / Reproduction (pre-fix, production)
curl /nonexistent-page-xyzand/pt/nonexistent-page-xyz200with generic<title>Yuri Cunha</title>curl -X POST /api/ai/content -d '{"action":"tags","content":"hello world test"}'(no auth)200with AI-generated tags at real provider costcurl '/api/mascot/latest-post?locale=xx'200 {"post":null}instead of falling back toenRoot cause
[locale]/[...rest]/page.tsxrendered the localized not-found UI as a regular component, so unmatched paths got HTTP 200. Crawlers and caches treat that as valid, indexable content./api/ai/contenthad norequireAdmingate, unlike its sibling/api/admin/translate, and has no caller anywhere in the site — an orphaned admin-capable endpoint open to the world.latest-posttreated any unknown?locale=as "no posts" (|| 'en'only catches null/empty), silently disabling the mascot's new-post notification.Fix
notFound()fromnext/navigation, rendering the same localized not-found UI with a real404status.POST /api/ai/contentis gated byrequireAdmin()(same pattern as/api/admin/translate). The metadataGETstays public.latest-postvalidates the requested locale againsti18n.localesand falls back to the default locale.Tests
catch-all-404.test.tsx: catch-all triggersnotFound()(red before: the old component rendered without erroring).ai-content-route.test.ts: new 401 case for unauthenticated POST; existing 429/400 cases updated to mock admin auth.mascot-latest-post-route.test.ts: unknown locale falls back toen; every supported locale passes through untouched.Validation
Pre-fix probes were run against production; post-fix behavior is covered by the regression tests above.
Residual risks
en/pt; users of the other five locales receive transactional email in English (pre-existing scope limitation, flagged for a future decision).The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment