Configuring Phaset
Phaset is designed to be straightforward to configure while giving you control when you need it. This guide covers everything from the bare minimum to advanced configuration scenarios.
Configuration Overview
Section titled “Configuration Overview”Phaset can be configured in three ways, with priorities from highest to lowest:
- CLI flags (e.g.,
phaset start --port 8080) - Environment variables (e.g.,
PORT=8080) - Configuration file (
phaset.config.json)
This flexibility means you can choose the approach that fits your deployment:
- Use config files for local development or VMs where you manage files directly
- Use environment variables for cloud platforms, containers, or CI/CD pipelines
- Use CLI flags for quick overrides during testing
Required Configuration
Section titled “Required Configuration”To run Phaset, you must provide these values:
Email Configuration (Required)
Section titled “Email Configuration (Required)”email.host- Your SMTP server hostnameemail.user- SMTP username (typically your email address)email.password- SMTP password or app-specific password
Bootstrap Configuration (Required)
Section titled “Bootstrap Configuration (Required)”phaset.bootstrap.organizationName- Your organization namephaset.bootstrap.adminEmail- Admin email address (receives first sign-in link)
Configuration File
Section titled “Configuration File”The configuration file is the most common way to set up Phaset, especially for local development and self-hosted deployments.
Creating the Configuration File
Section titled “Creating the Configuration File”phaset initThis creates phaset.config.json in your current directory with a template similar to this:
{ "email": { "emailSubject": "Sign In To Phaset", "user": "my_user@my_domain.net", "password": "my_password", "host": "smtp.my_host.net", "port": 465, "secure": true }, "auth": { "jwtSecret": "your-jwt-secret", "appUrl": "http://localhost:5173/app" }, "server": { "allowedDomains": ["*"] }, "phaset": { "licenseKey": "", "bootstrap": { "organizationName": "My Organization", "adminEmail": "me@my_domain.net" } }}Configuration File Location
Section titled “Configuration File Location”Phaset looks for phaset.config.json in your current working directory when you run phaset start. This means you can have different configurations for different deployments by running Phaset from different directories.
Environment Variables
Section titled “Environment Variables”Environment variables are ideal for cloud deployments, containers, and CI/CD pipelines where you don’t want to manage configuration files.
Email Configuration
Section titled “Email Configuration”| Environment Variable | Description | Default |
|---|---|---|
EMAIL_HOST | SMTP server hostname | - |
EMAIL_USER | SMTP username | - |
EMAIL_PASSWORD | SMTP password | - |
EMAIL_PORT | SMTP port | 587 |
EMAIL_SECURE | Use SSL/TLS (true/false) | true |
EMAIL_SUBJECT | Subject line for sign-in emails | "Sign In To Phaset" |
EMAIL_MAX_RETRIES | Retry attempts for failed emails | 2 |
Authentication Configuration
Section titled “Authentication Configuration”| Environment Variable | Description | Default |
|---|---|---|
AUTH_JWT_SECRET | Secret key for JWT signing | "your-jwt-secret" |
APP_URL | URL where users complete sign-in | "http://localhost:5173/app" |
AUTH_LINK_EXPIRY | Magic link expiry in seconds | 900 (15 min) |
AUTH_JWT_EXPIRY | JWT token expiry in seconds | 900 (15 min) |
AUTH_REFRESH_EXPIRY | Refresh token expiry in seconds | 604800 (7 days) |
AUTH_MAX_SESSIONS | Max concurrent sessions per user | 3 |
Server Configuration
Section titled “Server Configuration”| Environment Variable | Description | Default |
|---|---|---|
PORT | Port to listen on | 3000 |
HOST | Host to bind to | 0.0.0.0 |
ALLOWED_DOMAINS | Comma-separated list of allowed CORS origins | "http://localhost:5173,http://0.0.0.0:5173" |
Storage Configuration
Section titled “Storage Configuration”| Environment Variable | Description | Default |
|---|---|---|
DATA_DIR | Directory for database files | Current directory |
STORAGE_KEY | Encryption key for sensitive data | - |
Phaset Configuration
Section titled “Phaset Configuration”| Environment Variable | Description | Default |
|---|---|---|
BOOTSTRAP_ORG_NAME | Organization name for initial setup | - |
BOOTSTRAP_ADMIN_EMAIL | Admin email for initial setup | - |
PHASET_LICENSE_KEY | Your Phaset license key | "" |
DEMO_MODE | Enable demo mode (true/false) | false |
DEBUG | Enable debug logging (true/false) | false |
Example: Cloud Deployment with Environment Variables
Section titled “Example: Cloud Deployment with Environment Variables”In your App Platform configuration, add these environment variables:
APP_URL=https://phaset.yourcompany.com/appALLOWED_DOMAINS=https://phaset.yourcompany.comBOOTSTRAP_ORG_NAME=Your CompanyEMAIL_HOST=smtp.gmail.comEMAIL_PASSWORD=your-app-passwordEMAIL_PORT=465EMAIL_SECURE=trueAUTH_JWT_SECRET=your-secure-random-stringPass environment variables when running your container:
docker run -d \ -e EMAIL_HOST=smtp.gmail.com \ -e EMAIL_PASSWORD=your-app-password \ -e EMAIL_PORT=465 \ -e EMAIL_SECURE=true \ -e AUTH_JWT_SECRET=your-secure-random-string \ -e APP_URL=https://phaset.yourcompany.com/app \ -e BOOTSTRAP_ORG_NAME="Your Company" \ -e ALLOWED_DOMAINS=https://phaset.yourcompany.com \ -p 3000:3000 \ phaset:latestAdd environment variables to your service file:
[Service]Environment="APP_URL=https://phaset.yourcompany.com/app"Environment="ALLOWED_DOMAINS=https://phaset.yourcompany.com"Environment="BOOTSTRAP_ORG_NAME=Your Company"Environment="EMAIL_HOST=smtp.gmail.com"Environment="EMAIL_PASSWORD=your-app-password"Environment="EMAIL_PORT=465"Environment="EMAIL_SECURE=true"Environment="AUTH_JWT_SECRET=your-secure-random-string"CLI Flags
Section titled “CLI Flags”CLI flags provide the highest priority and are useful for quick overrides during development or testing.
Authentication Flags
Section titled “Authentication Flags”--jwtSecret <secret> JWT secret for token signing--magicLinkExpirySeconds <seconds> Magic link expiry time--jwtExpirySeconds <seconds> JWT expiry time--refreshTokenExpirySeconds <secs> Refresh token expiry time--maxActiveSessions <number> Max concurrent sessions--appUrl <url> Application URL for sign-in completion--debug Enable debug mode (flag, no value)Email Flags
Section titled “Email Flags”--emailSubject <subject> Email subject line--emailHost <hostname> SMTP server hostname--emailUser <username> SMTP username--emailPassword <password> SMTP password--emailPort <port> SMTP port number--emailSecure Use SSL/TLS (flag, no value)--emailMaxRetries <number> Max retry attemptsServer Flags
Section titled “Server Flags”--port <port> Port to listen on--host <hostname> Host to bind to--allowed <domain1,domain2,...> Comma-separated allowed domainsExamples of allowed domains:
// Allow specific domains (recommended for production)"allowedDomains": [ "https://phaset.example.com", "https://app.example.com"]
// Allow all domains (development only)"allowedDomains": ["*"]
// Allow localhost for development"allowedDomains": [ "http://localhost:5173", "http://localhost:3000"]Storage Flags
Section titled “Storage Flags”--db <directory> Database directory path--encryptionKey <key> Encryption key for storagePhaset Flags
Section titled “Phaset Flags”--licenseKey <key> Phaset license key--demoMode Enable demo mode (flag, no value)--bootstrapOrganizationName <name> Organization name--bootstrapAdminEmail <email> Admin email addressExample: Override Port and Debug Mode
Section titled “Example: Override Port and Debug Mode”phaset start --port 8080 --debugExample: Test with Different Config
Section titled “Example: Test with Different Config”phaset start --emailHost smtp.mailtrap.io --emailPort 2525 --demoModeConfiguration Priority
Section titled “Configuration Priority”When the same setting is provided in multiple ways, Phaset uses this priority order:
- CLI flags (highest priority)
- Environment variables
- Configuration file
- Default values (lowest priority)
Example Priority Resolution
Section titled “Example Priority Resolution”If you have:
- Config file:
"port": 3000 - Environment variable:
PORT=8080 - CLI flag:
--port 9000
Phaset will use port 9000 (CLI flag wins).
Complete Configuration Reference
Section titled “Complete Configuration Reference”Here’s a fully documented configuration file showing all available options:
{ "email": { "emailSubject": "Sign In To Phaset", "password": "your-smtp-password", "host": "smtp.gmail.com", "port": 465, "secure": true, "maxRetries": 2 }, "auth": { "jwtSecret": "your-secret-key-change-this", "magicLinkExpirySeconds": 900, "jwtExpirySeconds": 900, "refreshTokenExpirySeconds": 604800, "maxActiveSessions": 3, "appUrl": "https://phaset.yourcompany.com/app", "debug": false }, "server": { "port": 3000, "host": "0.0.0.0", "allowedDomains": [ "https://phaset.yourcompany.com", "http://localhost:5173" ] }, "storage": { "databaseDirectory": "", "encryptionKey": "", "debug": false }, "phaset": { "licenseKey": "", "demoMode": false, "bootstrap": { "organizationName": "Your Company", } }}Configuration Validation
Section titled “Configuration Validation”When you start Phaset, it validates your configuration and provides helpful error messages if required fields are missing:
$ phaset startError: Missing email.host valueError: Missing email.user valueError: Missing email.password valueError: Missing phaset.bootstrap.organizationName valueError: Missing phaset.bootstrap.adminEmail valueThis ensures you can’t accidentally start Phaset with incomplete configuration.
Common Configuration Scenarios
Section titled “Common Configuration Scenarios”Local Development
Section titled “Local Development”Goal: Quick setup for testing on your laptop
{ "email": { "password": "test-password", "host": "smtp.mailtrap.io", "port": 2525, "secure": false }, "auth": { "jwtSecret": "dev-secret", "appUrl": "http://localhost:5173/app" }, "server": { "allowedDomains": ["*"] }, "phaset": { "demoMode": true, "bootstrap": { "organizationName": "Dev Org", } }}Production VPS/VM
Section titled “Production VPS/VM”Goal: Secure production deployment on your infrastructure
{ "email": { "password": "secure-app-password", "host": "smtp.gmail.com", "port": 465, "secure": true }, "auth": { "jwtSecret": "generated-with-openssl-rand-base64-32", "appUrl": "https://phaset.yourcompany.com/app", "jwtExpirySeconds": 3600, "refreshTokenExpirySeconds": 2592000 }, "server": { "allowedDomains": [ "https://phaset.yourcompany.com" ] }, "phaset": { "licenseKey": "your-license-key-if-applicable", "bootstrap": { "organizationName": "Your Company", } }}Cloud Platform (Using Environment Variables)
Section titled “Cloud Platform (Using Environment Variables)”Goal: Deploy on DigitalOcean, AWS, or similar without managing config files
Set these environment variables in your platform’s dashboard:
# RequiredEMAIL_HOST=smtp.sendgrid.netEMAIL_USER=apikeyEMAIL_PASSWORD=your-sendgrid-api-keyBOOTSTRAP_ORG_NAME="Your Company"
# ImportantAUTH_JWT_SECRET=your-secure-random-stringAPP_URL=https://phaset.yourcompany.com/appALLOWED_DOMAINS=https://phaset.yourcompany.com
# OptionalEMAIL_PORT=465EMAIL_SECURE=truePORT=3000Security Recommendations
Section titled “Security Recommendations”JWT Secret
Section titled “JWT Secret”Always generate a strong, random JWT secret:
openssl rand -base64 32Never commit secrets to version control. Use environment variables or secret management tools.
Storage Encryption Key
Section titled “Storage Encryption Key”If you provide a storage.encryptionKey, Phaset encrypts sensitive data at rest. Generate it the same way:
openssl rand -base64 32CORS Configuration
Section titled “CORS Configuration”In production, never use "allowedDomains": ["*"]. Always specify exact domains:
"allowedDomains": [ "https://phaset.yourcompany.com"]