Skip to main content

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
GitHub OAuth application client IDWhere to get: https://github.com/settings/developersExample:
string
GitHub OAuth application client secretExample:
string
Google OAuth 2.0 client IDWhere to get: https://console.cloud.google.com/apis/credentialsExample:
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
Stripe Price ID for the Starter planWhere to get: https://dashboard.stripe.com/productsExample:
string
Stripe Price ID for the Growth planExample:

Email Service (Resend)

string
Resend API key for sending transactional emailsWhere to get: https://resend.com/api-keysExample:
string
Email address used as the sender for outgoing emailsRequirements: Must be a verified domain in ResendExample:

Redis Cache

string
Upstash Redis REST API URLWhere to get: https://console.upstash.com/redisExample:
string
Upstash Redis REST API authentication tokenNote: Not required for self-hosted RedisExample:

AI Engine APIs

Configure AI service providers for content analysis:
string
OpenAI API key for GPT modelsWhere to get: https://platform.openai.com/api-keysExample:
string
Perplexity AI API key for real-time search and analysisWhere to get: https://www.perplexity.ai/settings/apiExample:
string
Serper API key for Google Search integrationWhere to get: https://serper.dev/api-keyExample:

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
Sentry DSN for server-side error trackingWhere to get: https://sentry.io/settings/projects/Example:
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

Never commit your .env file to version control. The .env file is included in .gitignore by default.

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

Symptoms: API fails to start with database connection errorsSolutions:
  • Verify DATABASE_URL is correctly formatted
  • For Docker: Use service name (postgres) instead of localhost
  • Check PostgreSQL is running: docker compose ps postgres
  • Verify credentials match PostgreSQL configuration
Symptoms: Login fails or tokens are invalidSolutions:
  • Ensure JWT_SECRET and JWT_REFRESH_SECRET are set
  • Verify secrets are at least 64 characters
  • Check secrets are different from each other
  • Clear browser cookies and try again
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_URL matches OAuth configuration
  • For GitHub: Callback URL should be {NEXT_PUBLIC_APP_URL}/api/auth/callback/github
Symptoms: Caching fails or application is slowSolutions:
  • For Docker: Use redis://redis:6379 format
  • 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
Symptoms: Frontend shows network errorsSolutions:
  • Verify NEXT_PUBLIC_API_URL is publicly accessible
  • Check CORS settings in API server
  • Ensure FRONTEND_URL matches 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