Concordia requires several environment variables for database connections, authentication, email, and API configuration.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ishaq74/concordia/llms.txt
Use this file to discover all available pages before exploring further.
Setup
Create a.env file in the root directory:
Database Configuration
Controls which database to use during development:
true- Use test database (DATABASE_URL_TEST)false- Use local or production database
Whether to connect to the production database:
true- Use production database (DATABASE_URL_PROD)false- Use local or test database
PostgreSQL connection string for local development database.Format:Example:
PostgreSQL connection string for test database used during automated testing.Format:Example:
PostgreSQL connection string for production database.Format (Neon):Example:
Authentication Configuration
Secret key used to sign JWT tokens and secure sessions. Must be a strong random string.Generation:Example:
The base URL where your application is accessible. Used for generating callback URLs and verification links.Development:Production:
Do not include a trailing slash.
SMTP Email Configuration
Concordia uses SMTP for sending transactional emails (verification, password reset, notifications).The name of your SMTP provider. Common values:
gmailsendgridmailguncustom
The email address or username for SMTP authentication.
The password or app-specific password for SMTP authentication.
The “From” email address used in outgoing emails.
Optional SMTP Configuration
Custom SMTP server hostname. If not set, automatically determined from
SMTP_PROVIDER.SMTP server port. Common values:
587- TLS (recommended)465- SSL25- Unencrypted (not recommended)
Whether to use SSL/TLS:
true- Use SSL (port 465)false- Use STARTTLS (port 587)
Whether to use connection pooling for better performance.
Maximum number of simultaneous SMTP connections in the pool.
Time window in milliseconds for rate limiting.
Maximum number of emails to send within the rate limit window.
Alternative Email Provider: Resend
As an alternative to SMTP, you can use Resend for email delivery:API key from your Resend account. When set, Resend will be used instead of SMTP.
To use Resend, comment out or remove SMTP variables and set only
RESEND_API_KEY.Application Configuration
The environment mode for Node.js. Affects logging, error handling, and optimizations.Valid values:
development- Development mode with verbose loggingproduction- Production mode with optimizationstest- Test mode for automated testing
Public-facing API URL used by client-side code. Must be accessible from the browser.Development:Production:
Variables prefixed with
PUBLIC_ are exposed to client-side code. Never put secrets in PUBLIC_ variables.Complete Example Configuration
Here’s a complete.env file template with all variables:
.env
Testing Your Configuration
Test Database Connection
Test SMTP Configuration
Environment-Specific Files
- Development
- Production
- Testing
Create
.env.development:Security Best Practices
Never Commit Secrets
Never Commit Secrets
Add
.env* to your .gitignore:.gitignore
Generate Strong Secrets
Generate Strong Secrets
Use cryptographically secure random values:
Use Different Secrets Per Environment
Use Different Secrets Per Environment
Never reuse the same
BETTER_AUTH_SECRET across development, staging, and production.Rotate Secrets Regularly
Rotate Secrets Regularly
Change authentication secrets and API keys periodically, especially after:
- Team member departures
- Security incidents
- Suspected compromise
Limit Database Permissions
Limit Database Permissions
Use database users with minimal required permissions:
- Development: Full access to dev database only
- Production: No DDL permissions, only DML (SELECT, INSERT, UPDATE, DELETE)
Troubleshooting
Database Connection Failed
Database Connection Failed
Error:
Error: connect ECONNREFUSEDSolutions:- Ensure PostgreSQL is running:
- Check connection string format
- Verify username, password, and database name
- Test with
npm run db:check
SMTP Authentication Failed
SMTP Authentication Failed
Error:
Invalid login: 535-5.7.8 Username and Password not acceptedSolutions:- For Gmail: Use an App Password, not your account password
- Check
SMTP_USERandSMTP_PASSare correct - Verify SMTP provider settings
- Test with
npm run smtp:check
JWT Token Invalid
JWT Token Invalid
Error:
JsonWebTokenError: invalid signatureSolutions:- Ensure
BETTER_AUTH_SECRETis set and matches between environments - Check for whitespace or newlines in the secret
- Regenerate the secret if corrupted
Environment Variables Not Loading
Environment Variables Not Loading
Issue: Variables are undefined at runtimeSolutions:
- Ensure
.envfile is in the project root - Restart the development server after changing
.env - Check for typos in variable names
- Verify
dotenvis configured inastro.config.mjs
Next Steps
Database Setup
Learn about the database schema and migrations
Authentication
Configure authentication and user management