Overview
The NJ Rajat Mahotsav platform requires environment variables for Supabase authentication, database access, and Cloudflare R2 storage. This guide covers complete environment setup for local development and production deployment.Prerequisites
Before configuring your environment, ensure you have:- Node.js 18+ and npm installed
- A Supabase account and project created
- Cloudflare account with R2 and Images configured
- Google OAuth credentials (for admin portal)
Required Environment Variables
Supabase Configuration
These variables connect your application to Supabase for authentication and database operations.Finding Your Supabase Credentials:
- Go to your Supabase project dashboard
- Navigate to Settings → API
- Copy the Project URL and anon public key
Cloudflare R2 Configuration
R2 stores static assets and user uploads. Configure these variables for S3-compatible access:rajat-mahotsav-assets)Cloudflare Images (Optional)
The platform uses Cloudflare Images for optimized image delivery with variants:Local Development Setup
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
# Cloudflare R2
R2_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
R2_BUCKET_PREFIX=uploads/
Open http://localhost:3000 in your browser.
Environment Variable Validation
Testing Supabase Connection
Verify your Supabase credentials work:Testing R2 Connection
Verify R2 credentials by checking bucket access:Admin Domain Configuration
Admin access is restricted by email domain inlib/admin-auth.ts:
Common Issues
Supabase Connection Errors
Problem: “Invalid API key” or “Project not found” Solution:- Verify your
NEXT_PUBLIC_SUPABASE_URLhas no trailing slash - Confirm you’re using the anon public key, not the service role key
- Check the project is not paused in Supabase dashboard
R2 Access Denied
Problem: “403 Forbidden” when uploading files Solution:- Verify API token has Read & Write permissions
- Confirm bucket name matches exactly (case-sensitive)
- Check endpoint URL format:
https://<account-id>.r2.cloudflarestorage.com
Missing Environment Variables
Problem: “Cannot read property of undefined” errors Solution:- Restart development server after adding new variables
- Verify variable names match exactly (including
NEXT_PUBLIC_prefix) - Check
.env.localfile is in project root, not a subdirectory
Security Best Practices
Next Steps
After configuring your environment:- Configure Vercel Deployment
- Review the Security Checklist
- Set up Supabase Row Level Security policies
- Configure Google OAuth for admin access
