Skip to main content

Configuration guide

Configure your self-hosted Screenshothis instance with the right environment variables and settings for your deployment. This guide covers everything from basic setup to advanced production configurations.
Always check the source: Refer to the Screenshothis repository .env.example files for the most up-to-date configuration options. This guide is based on the actual environment variables used in the codebase.

Quick configuration

Start with this minimal setup and expand as needed:
1

Set up database connection

Configure PostgreSQL connection details in your apps/server/.env file.
2

Configure storage

Set up S3-compatible storage credentials for screenshot storage.
3

Add authentication secrets

Generate secure secrets for user authentication and API keys.
4

Customize performance settings

Adjust rate limits, timeouts, and screenshot quality settings.

Database configuration

Configure your PostgreSQL database connection:
string
required
Complete PostgreSQL connection string. This is the primary database configuration.
string
required
Database server hostname or IP address.
integer
default:"5432"
PostgreSQL server port.
string
required
Name of the Screenshothis database.
string
required
Database username for connections.
string
required
Database password for the specified user.

Redis configuration

Configure Redis for caching and session management:
string
required
Complete Redis connection string. This is the primary Redis configuration.
string
default:"localhost"
Redis server hostname (optional if using REDIS_URL).
integer
default:"6379"
Redis server port (optional if using REDIS_URL).
string
Redis password if authentication is required.

S3-compatible storage

Configure storage for screenshots using any S3-compatible service:
string
required
Access key ID for your S3-compatible storage service.
string
required
Secret access key for your S3-compatible storage service.
string
required
Storage region. Use auto for Cloudflare R2, or the appropriate region for your service.
string
required
Name of the bucket where screenshots will be stored.
string
required
Complete endpoint URL for your S3-compatible service.
string
S3 endpoint URL (usually same as AWS_URL).
boolean
default:"false"
Use path-style URLs instead of virtual-hosted style. Set to true for MinIO and some other services.

Storage provider examples

For production, we recommend AWS S3 for reliability, or DigitalOcean Spaces for cost-effectiveness. Cloudflare R2 offers excellent performance and free egress.

Application settings

Configure basic application behavior:
integer
default:"3000"
Port number for the server to listen on.
string
required
Environment mode. Use development for local work, production for live deployments.

Authentication and security

Configure authentication and API key generation:
string
required
Secret key for Better Auth authentication system. Must be a strong, random string.Generate a secure secret:
string
default:"ss"
Prefix for generated API keys. Use different prefixes for different environments.
Production security: Always use a strong, unique BETTER_AUTH_SECRET for production. Never reuse secrets across environments or share them in version control.

Frontend configuration

Configure the web interface in apps/web/.env:
string
required
URL of your backend API server.
string
Google OAuth client ID for Google authentication (optional).
string
Polar access token for billing integration (optional).
string
default:"sandbox"
Polar environment. Use sandbox for testing, production for live billing.
Google OAuth and Polar configurations are optional. You only need them if you want to offer Google sign-in or integrate with Polar for billing.

Performance and limits

Configure rate limiting and screenshot performance:
integer
default:"60000"
Rate limit window duration in milliseconds. Default is 1 minute (60000ms).
integer
default:"100"
Maximum requests allowed per rate limit window.
integer
default:"10"
Maximum number of screenshots that can be processed simultaneously.
integer
default:"30000"
Screenshot generation timeout in milliseconds. Default is 30 seconds.

Screenshot settings

Configure screenshot generation limits and defaults:
integer
default:"3840"
Maximum allowed screenshot width in pixels.
integer
default:"2160"
Maximum allowed screenshot height in pixels.
integer
default:"1280"
Default viewport width when not specified in requests.
integer
default:"720"
Default viewport height when not specified in requests.
integer
default:"30000"
Maximum time to wait for page loading in milliseconds.

Built-in security features

Screenshothis includes several built-in security measures that you should be aware of:
Automatically enforced limits:
  • Header size limit: 8 KB (8192 characters) per request
  • Cookie size limit: 4 KB (4096 characters) per request
  • URL length limit: Standard browser limits (2048 characters)
These limits prevent abuse and ensure consistent performance across all deployments.
Built-in rate limiting:
  • Per-user rate limiting via internal requestLimits system
  • Configurable via RATE_LIMIT_* environment variables
  • Automatic abuse protection
The system tracks usage per API key and enforces limits automatically.
Security auditing:
  • Every use of bypass_csp=true is logged server-side
  • Helps identify potential security issues
  • Enables compliance and security reviews
Monitor these logs regularly in production environments.
Automatic validation:
  • All API inputs validated using Zod schemas
  • URL validation prevents malicious requests
  • Parameter validation ensures data integrity
Input validation helps prevent injection attacks and maintains system stability.

Complete configuration examples

Minimal production setup

Backend configuration (apps/server/.env):
Frontend configuration (apps/web/.env):

High-performance production setup

For high-traffic deployments, use these optimized settings:

Development with external services

For development using cloud services instead of local Docker:

Docker deployment configuration

Using environment files

Organize your configuration using environment files:

Using Docker secrets

For enhanced security in production:

Configuration validation

Validate your configuration before deployment:
1

Check required variables

Ensure all required environment variables are set:
2

Test database connection

Verify your database connection:
3

Validate storage configuration

Test your S3-compatible storage:
4

Verify rate limits

Test rate limiting behavior with multiple requests to ensure limits are working correctly.

Troubleshooting configuration

Common causes:
  • Missing required environment variables
  • Invalid database connection string
  • Incorrect Redis URL format
  • S3 credentials or bucket access issues
Solution: Check the startup logs for specific error messages about missing or invalid configuration.
Common causes:
  • Incorrect DATABASE_URL format
  • Database server not accessible
  • Wrong credentials
  • Database doesn’t exist
Solution: Test connection manually: psql "postgresql://user:pass@host:port/db"
Common causes:
  • Invalid credentials
  • Bucket doesn’t exist
  • Wrong region configuration
  • Incorrect endpoint URL
Solution: Verify bucket exists and credentials have proper permissions (read/write access).

Next steps

Deployment Guide

Deploy your configured instance to production with Docker, Kubernetes, or cloud platforms

Troubleshooting

Common issues and solutions for self-hosted deployments

API Reference

Complete API documentation for your configured instance

GitHub Repository

View source code and latest configuration options