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:Complete PostgreSQL connection string. This is the primary database configuration.
Database server hostname or IP address.
PostgreSQL server port.
Name of the Screenshothis database.
Database username for connections.
Database password for the specified user.
- Development
- Production
Redis configuration
Configure Redis for caching and session management:Complete Redis connection string. This is the primary Redis configuration.
Redis server hostname (optional if using REDIS_URL).
Redis server port (optional if using REDIS_URL).
Redis password if authentication is required.
S3-compatible storage
Configure storage for screenshots using any S3-compatible service:Access key ID for your S3-compatible storage service.
Secret access key for your S3-compatible storage service.
Storage region. Use
auto for Cloudflare R2, or the appropriate region for your service.Name of the bucket where screenshots will be stored.
Complete endpoint URL for your S3-compatible service.
S3 endpoint URL (usually same as AWS_URL).
Use path-style URLs instead of virtual-hosted style. Set to
true for MinIO and some other services.Storage provider examples
- AWS S3
- DigitalOcean Spaces
- Cloudflare R2
- MinIO (Local)
Application settings
Configure basic application behavior:Port number for the server to listen on.
Environment mode. Use
development for local work, production for live deployments.Authentication and security
Configure authentication and API key generation:Secret key for Better Auth authentication system. Must be a strong, random string.Generate a secure secret:
Prefix for generated API keys. Use different prefixes for different environments.
Frontend configuration
Configure the web interface inapps/web/.env:
URL of your backend API server.
Google OAuth client ID for Google authentication (optional).
Polar access token for billing integration (optional).
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:Rate limit window duration in milliseconds. Default is 1 minute (60000ms).
Maximum requests allowed per rate limit window.
Maximum number of screenshots that can be processed simultaneously.
Screenshot generation timeout in milliseconds. Default is 30 seconds.
Screenshot settings
Configure screenshot generation limits and defaults:Maximum allowed screenshot width in pixels.
Maximum allowed screenshot height in pixels.
Default viewport width when not specified in requests.
Default viewport height when not specified in requests.
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:Request size limits
Request size limits
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)
Rate limiting system
Rate limiting system
Built-in rate limiting:
- Per-user rate limiting via internal
requestLimitssystem - Configurable via
RATE_LIMIT_*environment variables - Automatic abuse protection
CSP bypass auditing
CSP bypass auditing
Security auditing:
- Every use of
bypass_csp=trueis logged server-side - Helps identify potential security issues
- Enables compliance and security reviews
Input validation
Input validation
Automatic validation:
- All API inputs validated using Zod schemas
- URL validation prevents malicious requests
- Parameter validation ensures data integrity
Complete configuration examples
Minimal production setup
Backend configuration (apps/server/.env):
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
Application won't start
Application won't start
Common causes:
- Missing required environment variables
- Invalid database connection string
- Incorrect Redis URL format
- S3 credentials or bucket access issues
Database connection errors
Database connection errors
Common causes:
- Incorrect DATABASE_URL format
- Database server not accessible
- Wrong credentials
- Database doesn’t exist
psql "postgresql://user:pass@host:port/db"S3 storage errors
S3 storage errors
Common causes:
- Invalid credentials
- Bucket doesn’t exist
- Wrong region configuration
- Incorrect endpoint URL
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