Overview
OpenSight uses environment variables for configuration. Copy.env.example to .env and configure the variables for your deployment.
Required Variables
These variables must be configured for OpenSight to function:Database
string
required
PostgreSQL connection stringFormat:
postgresql://user:password@host:port/databaseExample:Authentication
string
required
Secret key for signing JWT access tokensRequirements: Minimum 64 characters, cryptographically randomExample:Generate secure secret:
string
required
Secret key for signing JWT refresh tokensRequirements: Minimum 64 characters, cryptographically random (different from JWT_SECRET)Example:Generate secure secret:
Application URLs
string
required
Public URL where the web application is hostedExample:
string
required
Public URL where the API server is accessibleExample:
string
required
Frontend application URL (used by API for CORS and redirects)Example:
Optional Variables
OAuth Authentication
Configure OAuth providers for user authentication:string
string
GitHub OAuth application client secretExample:
string
string
Google OAuth 2.0 client secretExample:
Payment Processing (Stripe)
string
Stripe secret API key for server-side operationsWhere to get: https://dashboard.stripe.com/apikeysExample:
string
Stripe webhook signing secret for verifying webhook eventsWhere to get: https://dashboard.stripe.com/webhooksExample:
string
Stripe publishable key for client-side operationsExample:
string
string
Stripe Price ID for the Growth planExample:
Email Service (Resend)
string
string
Email address used as the sender for outgoing emailsRequirements: Must be a verified domain in ResendExample:
Redis Cache
string
string
Upstash Redis REST API authentication tokenNote: Not required for self-hosted RedisExample:
AI Engine APIs
Configure AI service providers for content analysis:string
string
Perplexity AI API key for real-time search and analysisWhere to get: https://www.perplexity.ai/settings/apiExample:
string
File Uploads (Uploadthing)
string
Uploadthing secret key for server-side file operationsWhere to get: https://uploadthing.com/dashboardExample:
string
Uploadthing application IDExample:
Error Tracking (Sentry)
string
string
Sentry DSN for client-side error trackingExample:
Feature Flags
boolean
default:"true"
Enable or disable content scoring featuresExample:
boolean
default:"true"
Enable or disable webhook functionalityExample:
Server Configuration
number
default:"4000"
Port number for the API serverExample:
string
default:"development"
Node.js environment modePossible values:
development, production, testExample:Configuration Examples
Development Environment
.env
Production Environment (Docker)
.env
Production Environment (Managed Services)
.env
Security Best Practices
Generate Secure Secrets
Use cryptographically secure random strings:
Separate Environments
Use different credentials for development, staging, and production environments.
Rotate Secrets
Regularly rotate JWT secrets and API keys, especially after team member changes.
Use Secrets Management
In production, use secret management services (AWS Secrets Manager, HashiCorp Vault, etc.).
Validating Configuration
Verify your environment configuration:Troubleshooting
Database connection failed
Database connection failed
Symptoms: API fails to start with database connection errorsSolutions:
- Verify
DATABASE_URLis correctly formatted - For Docker: Use service name (
postgres) instead oflocalhost - Check PostgreSQL is running:
docker compose ps postgres - Verify credentials match PostgreSQL configuration
JWT authentication not working
JWT authentication not working
Symptoms: Login fails or tokens are invalidSolutions:
- Ensure
JWT_SECRETandJWT_REFRESH_SECRETare set - Verify secrets are at least 64 characters
- Check secrets are different from each other
- Clear browser cookies and try again
OAuth login fails
OAuth login fails
Symptoms: OAuth redirect fails or shows errorSolutions:
- Verify OAuth client IDs and secrets are correct
- Check redirect URIs in OAuth provider settings
- Ensure
NEXT_PUBLIC_APP_URLmatches OAuth configuration - For GitHub: Callback URL should be
{NEXT_PUBLIC_APP_URL}/api/auth/callback/github
Redis connection errors
Redis connection errors
Symptoms: Caching fails or application is slowSolutions:
- For Docker: Use
redis://redis:6379format - For Upstash: Verify both URL and token are set
- Test connection:
docker compose exec redis redis-cli ping - Check Redis is running:
docker compose ps redis
API not accessible from frontend
API not accessible from frontend
Symptoms: Frontend shows network errorsSolutions:
- Verify
NEXT_PUBLIC_API_URLis publicly accessible - Check CORS settings in API server
- Ensure
FRONTEND_URLmatches web application URL - For Docker: Verify port mappings are correct
Next Steps
Docker Deployment
Deploy OpenSight using Docker Compose
Self-Hosting Guide
Learn about self-hosting architecture and options