Configuration
RushChat configuration is primarily done through environment variables.
Configuration Overview
Environment Variables
Backend Configuration
Create a .env file in the project root directory (backend will prioritize loading the .env file in the project root).
Basic Services
PORT=5001 # Backend service port
NODE_ENV=development # Environment mode: development | production
CLIENT_URL=http://localhost:3000 # Frontend address (for CORS)
MAIN_DOMAIN=localhost # Main domain (set to actual domain in production)
Database
DB_HOST=localhost # Database host
DB_PORT=3306 # Database port
DB_USER=root # Database username
DB_PASSWORD=your_password # Database password
DB_NAME=rushchat # Database name
Solana RPC (Optional)
Red Packet Contracts (Optional)
# EVM chain red packet contract address
RED_PACKET_CONTRACT_ADDRESS=
# Solana red packet program ProgramId (Base58, typically 32~44 characters)
# Important: Must be "Program ProgramId", not wallet address
SOLANA_RED_PACKET_PROGRAM_ID=
Frontend Configuration
Create a .env file in the client/ directory:
Configuration Files
Database Configuration
Database configuration is read from environment variables, no additional configuration file needed.
Channel Rules Configuration
Channel rules are stored in the database and configured through the admin interface or API.
Production Environment Configuration
Railway Deployment
Configure environment variables in Railway project settings:
DB_HOST=<railway_mysql_host>
DB_PORT=3306
DB_USER=<railway_mysql_user>
DB_PASSWORD=<railway_mysql_password>
DB_NAME=<railway_mysql_database>
PORT=5001
NODE_ENV=production
CLIENT_URL=https://your-app.vercel.app
MAIN_DOMAIN=your-domain.com
Vercel Deployment
Configure environment variables in Vercel project settings:
REACT_APP_API_URL=https://your-backend.railway.app
REACT_APP_SOCKET_URL=https://your-backend.railway.app
Security Configuration
CORS Configuration
Backend controls CORS allowed origins through the CLIENT_URL environment variable.
Database Security
- Use strong passwords
- Restrict database access IP
- Regularly backup database
Production Environment Recommendations
- Use HTTPS
- Set strong password policy
- Enable database SSL connection
- Configure firewall rules
Environment Variable Priority
Backend environment variable loading order:
- Project root directory
.envfile - System environment variables
- Default values
Configuration Verification
Check Environment Variables
Test Database Connection
Common Configuration Issues
CORS Error
Ensure CLIENT_URL includes protocol (http:// or https://)
Database Connection Failed
Check database credentials and network connection
Port Conflict
Change PORT environment variable and update frontend REACT_APP_SOCKET_URL