Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MatthewSabia1/SubPirate-Pro/llms.txt
Use this file to discover all available pages before exploring further.
Environment setup
SubPirate Pro requires several environment variables to function properly. This guide documents all available configuration options, their purpose, and how to set them up correctly.Quick setup
Environment variables reference
Client variables (VITE_*)
Variables prefixed with
VITE_ are bundled into the browser and are publicly accessible. Never put secrets in VITE_* variables.VITE_SUPABASE_URL
Required: YesType: String (URL)
Example:
https://abcdefghijklmnop.supabase.co
Your Supabase project URL. Find this in your Supabase project settings under “API” → “Project URL”.
VITE_SUPABASE_ANON_KEY
Required: YesType: String (JWT)
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Your Supabase anonymous (public) key. Find this in your Supabase project settings under “API” → “Project API keys” → “anon public”.
The anon key is safe to expose in the browser - it only grants access permitted by your row-level security (RLS) policies.
VITE_REDDIT_APP_ID
Required: YesType: String
Example:
abc123DEFghi
Your Reddit app client ID. Register an app at reddit.com/prefs/apps with type “web app” to get this.
VITE_REDDIT_REDIRECT_URI
Required: NoType: String (URL)
Example:
http://localhost:5173/auth/reddit/callback
Optional exact callback URI sent to Reddit’s /api/v1/authorize endpoint. Use this to force a single canonical callback URI across dev/prod hosts.
APP_ORIGIN or PUBLIC_ORIGIN.
VITE_LOCAL_ADMIN_BYPASS
Required: No (development only)Type: Boolean (
0 or 1)Default:
0
Enables a “Local Admin Login (dev)” button on the login page for quick testing without Supabase auth.
VITE_LOCAL_ADMIN_TOKEN
Required: No (development only)Type: String
Example:
dev-admin-token-12345
Token used for local admin bypass authentication. Required when VITE_LOCAL_ADMIN_BYPASS=1.
Server variables
PORT
Required: NoType: Number
Default:
8787
Port for the Express API server in local development.
SUPABASE_URL
Required: YesType: String (URL)
Example:
https://abcdefghijklmnop.supabase.co
Server-side Supabase project URL. Should match VITE_SUPABASE_URL.
SUPABASE_ANON_KEY
Required: YesType: String (JWT)
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Server-side Supabase anonymous key. Should match VITE_SUPABASE_ANON_KEY.
SUPABASE_SERVICE_ROLE_KEY
Required: No (optional for admin operations)Type: String (JWT)
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Supabase service role key with full database access, bypassing RLS. Find this in Supabase project settings under “API” → “Project API keys” → “service_role secret”.
OPENROUTER_API_KEY
Required: Yes (for subreddit analysis)Type: String
Example:
sk-or-v1-abc123...
OpenRouter API key for AI-powered subreddit analysis. Sign up at openrouter.ai and create an API key.
SubPirate Pro uses the google/gemini-3-flash-preview model for analysis.
OpenRouter charges per-token usage. Monitor your usage at openrouter.ai/activity.
REDDIT_CLIENT_ID
Required: YesType: String
Example:
abc123DEFghi
Reddit app client ID. Should match VITE_REDDIT_APP_ID.
REDDIT_CLIENT_SECRET
Required: YesType: String
Example:
xyz789ABCdef-secretkey
Reddit app client secret. Find this in your Reddit app settings at reddit.com/prefs/apps.
REDDIT_USER_AGENT
Required: YesType: String
Example:
web:SubPirate:1.0.0 (by /u/yourusername)
User agent string for Reddit API requests. Reddit requires a unique user agent following their format.
Replace
yourusername with your actual Reddit username.REDDIT_REDIRECT_URI
Required: NoType: String (URL)
Example:
http://localhost:5173/auth/reddit/callback
Optional exact callback URI expected by the token exchange endpoint. Keep this aligned with VITE_REDDIT_REDIRECT_URI when set.
TOKEN_ENCRYPTION_KEY
Required: YesType: String (Base64)
Example:
abcDEF123xyz==
Base64-encoded 32-byte key for AES-256-GCM encryption of Reddit refresh tokens.
Generate with:
APP_ORIGIN
Required: YesType: String (URL)
Example:
http://localhost:5173
Base origin for constructing OAuth callback URIs. Used to compute the Reddit redirect URI as ${APP_ORIGIN}/auth/reddit/callback.
In production, this must be a valid
https:// origin.PUBLIC_ORIGIN
Required: NoType: String (URL)
Example:
https://your-domain.com
Alternative to APP_ORIGIN for production deployments. Takes precedence if set.
CORS_ORIGINS
Required: YesType: String (comma-separated URLs)
Example:
http://localhost:5173,http://127.0.0.1:5173
Comma-separated list of allowed browser origins for API requests.
SPEAKEASY_PASSWORD
Required: Only if using/speakeasy endpointsType: String
Example:
secret-speakeasy-pass-123
Password required to use /speakeasy validate/redeem endpoints (legacy access flow).
Campaign scheduler variables
CAMPAIGN_SCHEDULER_ENABLED
Required: NoType: Boolean (
true or false)Default:
true
Enables the campaign scheduler and cron endpoint.
CAMPAIGN_MAX_WORKERS
Required: NoType: Number
Default:
1
Maximum number of concurrent campaign workers.
CRON_SECRET
Required: Yes (for production cron)Type: String
Example:
cron-secret-abc123
Secret token passed in the Authorization header when calling /api/campaigns/cron. Prevents unauthorized campaign execution.
CRON_IP_ALLOWLIST
Required: NoType: String (comma-separated IPs)
Example:
192.168.1.1,10.0.0.1
Optional comma-separated IP allow-list for cron endpoint security. Checks the first IP from x-forwarded-for header.
Local development variables
LOCAL_ADMIN_BYPASS
Required: No (development only)Type: Boolean (
0 or 1)Default:
0
Server-side local admin bypass flag. Should match VITE_LOCAL_ADMIN_BYPASS.
LOCAL_ADMIN_TOKEN
Required: No (development only)Type: String
Example:
dev-admin-token-12345
Server-side local admin token. Should match VITE_LOCAL_ADMIN_TOKEN.
MAILPIT_ORIGIN
Required: NoType: String (URL)
Default:
http://127.0.0.1:54324
Mailpit origin for viewing auth emails during local development with Supabase.
Mailpit runs automatically when you start local Supabase with
supabase start. Access it at the configured origin to view email confirmations and password resets.Stripe variables (optional)
SubPirate Pro currently has free access placeholders only. These Stripe variables are for future billing implementation.
STRIPE_SECRET_KEY
Required: NoType: String
Example:
sk_test_...
Stripe secret API key.
STRIPE_WEBHOOK_SECRET
Required: NoType: String
Example:
whsec_...
Stripe webhook signing secret.
STRIPE_PRICE_* variables
Required: NoType: String
Example:
price_...
Stripe price IDs for different subscription tiers:
Environment-specific configurations
Local development
Production (Vercel)
Security best practices
Never commit secrets
Add
.env to .gitignore and use .env.example as a templateRotate keys regularly
Periodically regenerate API keys and encryption keys
Use VITE_ carefully
Only use
VITE_ prefix for truly public valuesSecure encryption keys
Generate strong
TOKEN_ENCRYPTION_KEY and store securelyValidation and testing
Check required variables
Run smoke tests
Secret scanning
Run this before committing to catch any accidentally exposed secrets.
Troubleshooting
”Missing required environment variable”
Check that you’ve set all required variables for your environment:- Local dev: Minimum set includes Supabase, Reddit, OpenRouter, and encryption key
- Production: All server variables plus proper origins and CORS configuration
”CORS error” when calling API
VerifyCORS_ORIGINS includes your frontend origin exactly as it appears in the browser:
“Reddit OAuth redirect mismatch”
Ensure these values align:VITE_REDDIT_REDIRECT_URI(if set)REDDIT_REDIRECT_URI(if set)- Redirect URIs in your Reddit app settings
- Computed URI from
APP_ORIGIN
”Token encryption error”
VerifyTOKEN_ENCRYPTION_KEY is:
- Exactly 32 bytes before base64 encoding
- Base64-encoded string
- Not corrupted with extra whitespace
Ready to start building?
Head to the quickstart guide to begin using SubPirate Pro