Environment Variables

Usertour uses environment variables to configure various application parameters. Here's a detailed explanation of the environment variables:

Environment VariableRequiredDescription
Database Configuration
DATABASE_URLYesPostgreSQL database connection URL
Server Configuration
NEST_SERVER_PORTNoNestJS server port, default is 3000
NODE_ENVYesNode.js environment
Email Service Configuration
EMAIL_HOSTYesEmail server address
EMAIL_PORTYesEmail server port
EMAIL_USERYesEmail service account
EMAIL_PASSYesEmail service password
Redis Configuration
Redis_HOSTYesRedis server address
Redis_PORTYesRedis server port
Redis_PASSNoRedis server password
Application Configuration
APP_HOMEPAGE_URLYesApplication homepage URL
API_URLNoGraphQL API endpoint, default is /graphql
USERTOUR_TOKENNoUsertour Environment token
AWS S3 Configuration
AWS_S3_REGIONYesAWS S3 region
AWS_S3_ENDPOINTYesAWS S3 endpoint
AWS_S3_ACCESS_KEY_IDYesAWS S3 access key ID
AWS_S3_SECRET_ACCESS_KEYYesAWS S3 secret access key
AWS_S3_BUCKETYesAWS S3 bucket name
AWS_S3_DOMAINYesAWS S3 domain
Analytics Configuration
POSTHOG_KEYNoPostHog API key
POSTHOG_HOSTNoPostHog host URL
Authentication Configuration
JWT_SECRETYesJWT token secret key
JWT_EXPIRATION_TIMEYesJWT token expiration time (e.g. 1h)
JWT_REFRESH_EXPIRATION_TIMEYesJWT refresh token expiration time (e.g. 7d)
Email Authentication
EMAIL_AUTH_ENABLEDNoEnable/disable email authentication
EMAIL_SENDERNoEmail sender name and address
GitHub Authentication
GITHUB_AUTH_ENABLEDNoEnable/disable GitHub authentication
GITHUB_CLIENT_IDNoGitHub OAuth client ID
GITHUB_CLIENT_SECRETNoGitHub OAuth client secret
GITHUB_CALLBACK_URLNoGitHub OAuth callback URL
Google Authentication
GOOGLE_AUTH_ENABLEDNoEnable/disable Google authentication
GOOGLE_CLIENT_IDNoGoogle OAuth client ID
GOOGLE_CLIENT_SECRETNoGoogle OAuth client secret
GOOGLE_CALLBACK_URLNoGoogle OAuth callback URL
Other Configuration
LOGIN_REDIRECT_URLNoURL to redirect after login

Important Notes

  • For local development, APP_HOMEPAGE_URL can be set to http://[ip]:[port]
  • For production environments, make sure to modify the default security-related configurations (such as JWT secrets)
  • DATABASE_URL includes the database connection parameters with SSL mode preference

Configuration Example (.env)

Create a .env file in the project root directory. You can refer to the following example:

# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# Server Configuration
NEST_SERVER_PORT=3000
NODE_ENV=production

# Email Service Configuration
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_password

# Redis Configuration
Redis_HOST=localhost
Redis_PORT=6379
Redis_PASS=

# Application Configuration
APP_HOMEPAGE_URL=http://localhost:8011
API_URL=
USERTOUR_TOKEN=your_token

# AWS S3 Configuration
AWS_S3_REGION=your_region
AWS_S3_ENDPOINT=your_endpoint
AWS_S3_ACCESS_KEY_ID=your_access_key
AWS_S3_SECRET_ACCESS_KEY=your_secret_key
AWS_S3_BUCKET=your_bucket
AWS_S3_DOMAIN=your_domain

# Analytics Configuration
POSTHOG_KEY=your_posthog_key
POSTHOG_HOST=your_posthog_host

# JWT Configuration
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION_TIME=1h
JWT_REFRESH_EXPIRATION_TIME=7d

# Email Authentication
EMAIL_AUTH_ENABLED=true
EMAIL_SENDER=Your App <support@example.com>

# GitHub Authentication
GITHUB_AUTH_ENABLED=true
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_CALLBACK_URL=http://localhost:8011/api/auth/github/callback

# Google Authentication
GOOGLE_AUTH_ENABLED=true
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:8011/api/auth/google/callback

# Login Configuration
LOGIN_REDIRECT_URL=http://localhost:8011/env/1/flows

Note: Do not use these example values directly. Configure them according to your actual environment. Make sure to use secure keys and passwords in production environments.

Subscribe to Newsletter

By subscribing, you agree with Usertour's Terms of Service and Privacy Policy.