Caching Authenticated API Routes in Nuxt with Nitro
I added caching to an admin endpoint and it broke authentication, and almost leaked user session.
HumanOnlyWeb
π writer of code. drinker of coffee. human on the web.I added caching to an admin endpoint and it broke authentication, and almost leaked user session.
As your fullstack Nuxt app grows, you'll need more structure than just routes calling the database directly. Here's a layered architecture that scales with complexity.
Catch invalid route parameters before they hit your backend. Here's how to validate them client-side using Zod and Nuxt's definePageMeta.
Stop writing manual validation logic in every API route. Here are some utility functions that make Zod validation painless in Nuxt.
Wrangler 3+ removed the ability to easily emulate public R2 buckets locally. Here's a simple Nuxt server route workaround.