Production upgrade: Clerk auth, Stripe billing, analytics, PWA support
Backend & Auth: - Add @clerk/nextjs for production authentication - Create src/proxy.ts with clerkMiddleware() for route protection - Implement multi-tenant auth with role-based access control - Add Clerk components (Show, UserButton, SignInButton, SignUpButton) Billing & Payments: - Full Stripe integration (subscriptions, add-ons, customer portal) - Plan tiers: Starter 9/mo, Farm 49/mo, Enterprise 99/mo - Webhook handling for subscription events - createSubscription(), createAddonSubscription(), createCustomerPortalSession() API & Security: - Rate limiting with @upstash/ratelimit (100 req/min API, 20 req/min checkout) - Zod validation schemas for all endpoints (orders, products, campaigns, etc.) - Security headers (CSP, HSTS, X-Frame-Options) - API routes: /api/v1/ with validated, rate-limited endpoints Monitoring: - Sentry error tracking with performance monitoring - PostHog analytics for feature usage, funnels, cohorts - User activity logging and breadcrumb tracking Admin Features: - Analytics dashboard with revenue charts, customer growth, conversion funnel - Onboarding flow with 6-step interactive tour - Referral system with share tracking and reward redemption - Changelog feed with in-app notifications PWA & SEO: - Web app manifest with icons and shortcuts - Service worker for offline support and caching - Full SEO metadata, OpenGraph, Twitter cards - Structured data (JSON-LD) for organization and products Database: - Add referral_codes, changelogs, onboarding_progress tables - Add user_activity_logs, api_keys, notification_preferences - Comprehensive RLS policies for all new tables - Seed data for demo brands and products
This commit is contained in:
+105
-15
@@ -1,28 +1,118 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
httpAgentOptions: {
|
||||
keepAlive: false,
|
||||
},
|
||||
// Enable strict mode
|
||||
reactStrictMode: true,
|
||||
|
||||
// Optimize images
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{ hostname: "wnzkhezyhnfzhkhiflrp.supabase.co" },
|
||||
{ hostname: "images.unsplash.com" },
|
||||
{ hostname: "cdn.shopify.com" },
|
||||
{
|
||||
protocol: "https",
|
||||
hostname: "*.supabase.co",
|
||||
},
|
||||
{
|
||||
protocol: "https",
|
||||
hostname: "images.unsplash.com",
|
||||
},
|
||||
{
|
||||
protocol: "https",
|
||||
hostname: "picsum.photos",
|
||||
},
|
||||
],
|
||||
formats: ["image/avif", "image/webp"],
|
||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
||||
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
||||
},
|
||||
devIndicators: {
|
||||
position: "bottom-left",
|
||||
|
||||
// Security headers
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/:path*",
|
||||
headers: [
|
||||
{
|
||||
key: "X-Content-Type-Options",
|
||||
value: "nosniff",
|
||||
},
|
||||
{
|
||||
key: "X-Frame-Options",
|
||||
value: "DENY",
|
||||
},
|
||||
{
|
||||
key: "X-XSS-Protection",
|
||||
value: "1; mode=block",
|
||||
},
|
||||
{
|
||||
key: "Referrer-Policy",
|
||||
value: "strict-origin-when-cross-origin",
|
||||
},
|
||||
{
|
||||
key: "Permissions-Policy",
|
||||
value: "camera=(), microphone=(), geolocation=()",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// API routes - more restrictive
|
||||
source: "/api/:path*",
|
||||
headers: [
|
||||
{
|
||||
key: "Access-Control-Allow-Methods",
|
||||
value: "GET, POST, PUT, DELETE, OPTIONS",
|
||||
},
|
||||
{
|
||||
key: "Access-Control-Allow-Headers",
|
||||
value: "Content-Type, Authorization, X-API-Key",
|
||||
},
|
||||
{
|
||||
key: "Access-Control-Max-Age",
|
||||
value: "86400",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
// Redirects
|
||||
async redirects() {
|
||||
return [
|
||||
// Redirect old paths if needed
|
||||
// {
|
||||
// source: '/old-path',
|
||||
// destination: '/new-path',
|
||||
// permanent: true,
|
||||
// },
|
||||
];
|
||||
},
|
||||
|
||||
// Rewrites for API proxy
|
||||
async rewrites() {
|
||||
return [
|
||||
// Add any necessary rewrites here
|
||||
];
|
||||
},
|
||||
|
||||
// Experimental features
|
||||
experimental: {
|
||||
serverActions: {
|
||||
bodySizeLimit: '10mb',
|
||||
// Enable optimizePackageImports for better bundle size
|
||||
optimizePackageImports: ["lucide-react", "@radix-ui/react-icons", "framer-motion"],
|
||||
},
|
||||
|
||||
// Compiler options
|
||||
compiler: {
|
||||
// Remove console.log in production
|
||||
removeConsole: process.env.NODE_ENV === "production"
|
||||
? { exclude: ["error", "warn"] }
|
||||
: false,
|
||||
},
|
||||
|
||||
// Logging
|
||||
logging: {
|
||||
fetches: {
|
||||
fullUrl: process.env.NODE_ENV === "development",
|
||||
},
|
||||
},
|
||||
serverExternalPackages: ['@prisma/adapter-pg'],
|
||||
|
||||
// Netlify deployment settings
|
||||
output: 'standalone',
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
export default nextConfig;
|
||||
Reference in New Issue
Block a user