#Architecture#Web Development
Edge-Compatible NextAuth v5 & Strategy-Pattern Cloud Storage in Next.js App Router
Nov 5, 2026·4 min read
Splitting Edge middleware auth from Node database drivers and isolating Cloudinary v2 behind an S3-ready storage interface.
Splitting Edge and Node Auth Configurations
Edge middleware cannot bundle Node-native dependencies such as pg or bcryptjs. By keeping stateless JWT authorization callbacks in auth.config.ts and extending them in auth.ts for Node API routes, protected /admin/* routes stay fast and secure.
Zero-Lock-In Media Uploads
production.ts
export interface StorageProvider {
upload(buffer: Buffer, filename: string): Promise<{ url: string; publicId: string }>;
delete(publicId: string): Promise<void>;
}Storing both the CDN url and provider publicId lets admins upload auto-optimized WebP assets in parallel and cleanly delete remote cloud objects when products are updated.
Written by Rahul Tanwar