Environment Variables
VizBoard requires several environment variables to run properly. Create a.env file in the project root with the following configuration:
Required Variables
All variables listed below are required for the application to function correctly.
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string for the main application database | postgresql://postgres:postgres@localhost:5432/vizboard_main?schema=public |
AUTH_SECRET | Secret key for NextAuth.js JWT token signing and encryption (minimum 32 characters) | Generated using openssl rand -base64 32 |
NEXTAUTH_URL | Base URL of your application for authentication callbacks | http://localhost:3000 (development) or your production URL |
ENCRYPTION_KEY | AES-256-GCM encryption key for securing external database credentials (must be 32 bytes in base64) | Generated using Node.js crypto module |
Optional Variables
| Variable | Description | Default |
|---|---|---|
NODE_ENV | Application environment mode | development |
Security Key Generation
VizBoard requires two cryptographically secure keys for authentication and encryption. Follow these steps to generate them:Generate AUTH_SECRET
The This will output a random base64-encoded string like:Copy this value to your
AUTH_SECRET is used by NextAuth.js to sign and encrypt JWT tokens. Generate a secure random string using OpenSSL:.env file as AUTH_SECRET.Generate ENCRYPTION_KEY
The This will output a 32-byte base64-encoded string like:Copy this value to your
ENCRYPTION_KEY is used to encrypt external database credentials before storing them in the database. It must be exactly 32 bytes encoded in base64.Generate it using Node.js:.env file as ENCRYPTION_KEY.Security Best Practices
Credential Encryption
VizBoard uses AES-256-GCM encryption to protect external database connection credentials. All database passwords and connection strings are encrypted before being stored in the main database, ensuring sensitive information is never stored in plain text.
Production Considerations
Key Rotation
If you need to rotate theENCRYPTION_KEY:
- Do not simply change the key - this will break decryption of existing credentials
- Implement a migration strategy to re-encrypt existing data with the new key
- Consider implementing a key versioning system for seamless rotation
Key rotation requires careful planning. Contact your system administrator or review the codebase for migration strategies before rotating encryption keys.
Next Steps
Once your environment is configured:- Set up your databases using Docker Compose
- Run Prisma migrations to initialize your database schema
- Start the development server with
npm run dev
Troubleshooting
Invalid AUTH_SECRET Length
If you see authentication errors, ensure yourAUTH_SECRET is at least 32 characters long. Use the OpenSSL command above to generate a proper key.
Database Connection Failed
Verify that:- Your PostgreSQL database is running (via Docker or locally)
- The
DATABASE_URLconnection string is correct - The database name, user, and password match your configuration
- The port (default 5432) is not blocked by a firewall
Encryption/Decryption Errors
If you encounter encryption errors:- Ensure
ENCRYPTION_KEYis exactly 32 bytes in base64 format - Use the Node.js command above to generate a valid key
- Do not manually edit or truncate the generated key
