Postmortem·
Postmortem: Nuxt Content 404s on Staging Deployments
Debugging missing content and 404 errors when deploying Nuxt Content to Cloudflare D1.
1. The Issue
- Symptom: Direct URLs or page reloads to
/blog/*and/help/*threw a 404 error in the Staging environment. - Impact: Content routing in Staging was broken for direct links.
2. Root Cause
- Empty Database: The Staging Cloudflare D1 database was completely empty. It lacked all Nuxt Content tables.
- My Mistake: I failed to understand that NuxtHub requires the specific
nuxthub deployCLI command to automatically sync the database. - Because I was using the vanilla
wrangler deploycommand in mypackage.jsonscripts, the automated database synchronization was entirely bypassed, leaving the Staging database empty.
3. Why It Was Confusing
The issue was masked by an illusion that client-side navigation was working:
- Index Pages (
/blogs): Code used.all(). Against an empty database, it returned[]. The page loaded successfully but silently displayed 0 posts. - Individual Posts (
/blog/post-name): Code used.first(). Against an empty database, it returnednull, which explicitly triggered a 404 error page.
4. The Fix
- Immediate: Manually synced the Staging database using the generated SQL dump:
wrangler d1 execute project-staging --remote --file .nuxt/content/sql_dump.txt - Long-term: Hardcoded the database synchronization step directly into the
package.jsondeployment scripts to ensure the deployment command always seeds the D1 database moving forward.
Comments
INCIDENT_REPORT
Postmortem: Serverless HTTP Driver Transaction Failures
Previous
Postmortem: Serverless HTTP Driver Transaction Failures
Why database transactions fail in serverless HTTP drivers and how to architect around them using compensating transactions.
INCIDENT_REPORT
Postmortem: 500 Internal Server Error on ISR Routes
Next
Postmortem: 500 Internal Server Error on ISR Routes
Resolving Nuxt Content payload extraction issues and hydration crashes on ISR routes.
