feat: implement sql dump encryption
Description
This PR introduces encrypted SQL dumps to Nuxt Content v3, allowing prerendered content dumps to be safely hosted on a CDN or static platform without exposing raw .sql data.
When enabled, dumps are AES-256-GCM encrypted at build time and decrypted in the browser only after the client requests a short-lived key from your app (post-authentication).
Key points
-
🔒 New
content.encryptionoption innuxt.config.ts-
enabled: trueenables encrypted dumps and key endpoint -
masterKey(optional) – base64(32 bytes); if omitted, one is generated at build time
-
-
✨ Adds runtime API endpoints:
-
GET /__nuxt_content/:collection/sql_dump.enc→ encrypted dump -
GET /api/__nuxt_content/:collection/key→ returns derived AES key (must be protected by your auth middleware) - Legacy
sql_dump.txtroutes remain available if encryption is disabled
-
-
🧩 Middleware example added for access control of private collections
-
📚 Documentation updated with new guides:
-
docs/content/docs/1.getting-started/3.configuration.md(content.encryption) -
docs/content/docs/8.advanced/9.private.md(full guide on encrypted dumps)
-
-
🛠 Internal changes:
- New
runtime/internal/encryption.tsutilities (HKDF, AES-GCM, envelope handling) - Client & server loaders updated to support decrypt-and-hydrate flow
- Shared dumps preset (
src/presets/shared-dumps.ts) ensures consistent handling across Node, Cloudflare, and NuxtHub
- New
Type of change
- [ ] 📖 Documentation
- [ ] 🐞 Bug fix
- [ ] 👌 Enhancement
- [x] ✨ New feature
- [ ] ⚠️ Breaking change
Checklist
- [x] Added docs for new config (
content.encryption) - [x] Updated presets (
node,cloudflare,nuxthub) to support encrypted dumps - [x] Added runtime encryption/decryption logic
- [x] Ensured backwards compatibility with legacy
.sqldumps
@oripka is attempting to deploy a commit to the NuxtLabs Team on Vercel.
A member of the Team first needs to authorize it.