Overview
JCV Fitness uses environment variables to configure connections to Supabase, payment providers, and deployment platforms. All environment variables should be stored in.env.local for local development.
Environment File Setup
Create a.env.local file in the root of your project:
Required Variables
Supabase Configuration
These variables are required for authentication, database access, and storage..env.local
Get Supabase URL
- Go to Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the Project URL as
NEXT_PUBLIC_SUPABASE_URL
Get Anonymous Key
From the same API settings page:
- Copy the anon public key as
NEXT_PUBLIC_SUPABASE_ANON_KEY
MercadoPago Configuration
Required for payment processing (primary payment provider)..env.local
Create MercadoPago Application
- Go to MercadoPago Developer Panel
- Create a new application or select existing one
- Copy your Public Key (for client-side)
- Copy your Access Token (for server-side)
Optional Variables
Wompi Configuration
Future payment provider integration (currently not active)..env.local
Email Service (Resend)
For sending subscription reminder emails..env.local
How to get a Resend API key
How to get a Resend API key
- Sign up at Resend
- Navigate to API Keys in the dashboard
- Create a new API key
- Copy and paste it as
RESEND_API_KEY
Cloudflare Configuration
For deploying the webhook worker and hosting on Cloudflare Pages..env.local
Environment Variable Prefixes
Next.js requires the
NEXT_PUBLIC_ prefix for any variable that should be accessible in the browser.| Prefix | Access | Use Case |
|---|---|---|
NEXT_PUBLIC_ | Client + Server | Public configuration (API URLs, public keys) |
| No prefix | Server only | Secrets (service keys, tokens, private keys) |
Example Configuration
Here’s a complete example.env.local file:
.env.local
Validation
You can verify your environment variables are loaded correctly:Deployment Environments
Cloudflare Pages
When deploying to Cloudflare Pages, set these environment variables in the dashboard:Navigate to Environment Variables
- Go to your Cloudflare Pages project
- Click Settings → Environment variables
Cloudflare Workers
For the MercadoPago webhook worker, set secrets using Wrangler:Security Best Practices
Rotate keys regularly
Rotate keys regularly
- Change Supabase service role keys every 90 days
- Update MercadoPago tokens if compromised
- Use different keys for staging and production
Never commit secrets
Never commit secrets
- Always use
.env.local(already in.gitignore) - Never hardcode keys in source files
- Use environment variables for all sensitive data
Limit key permissions
Limit key permissions
- Use anonymous keys for client-side Supabase access
- Use service role keys only in server-side code
- Enable Row Level Security (RLS) on all tables
Troubleshooting
Environment variables not loading
- Ensure your
.env.localfile is in the project root - Restart the Next.js dev server after changing
.env.local - Check for typos in variable names
- Verify no trailing spaces or quotes
CORS errors from Supabase
- Verify your Supabase URL is correct
- Check that your site URL is added to Supabase’s allowed URLs:
- Go to Authentication → URL Configuration
- Add
http://localhost:3000for development
Payment integration not working
- Ensure you’re using the correct environment (test vs production)
- Verify MercadoPago keys match your account region
- Check webhook URL is configured in MercadoPago dashboard
Next Steps
Database Setup
Now that your environment is configured, set up your Supabase database with migrations