Configuration
Learn how to configure the application for your specific needs.
Environment Variables
Create a .env.local
file in your project root with the following variables:
# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
# API Configuration
API_BASE_URL=https://api.example.com
API_TIMEOUT=30000
# Feature Flags
ENABLE_ANALYTICS=true
ENABLE_CACHING=false
Application Settings
Database Settings
Configure your database connection in config/database.js
:
module.exports = {
development: {
dialect: 'postgresql',
host: process.env.DB_HOST || 'localhost',
port: process.env.DB_PORT || 5432,
database: process.env.DB_NAME,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
},
production: {
use_env_variable: 'DATABASE_URL',
dialect: 'postgresql',
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false
}
}
}
};
Logging
Configure logging levels and outputs:
const config = {
level: process.env.LOG_LEVEL || 'info',
format: 'json',
transports: [
new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
new winston.transports.File({ filename: 'logs/combined.log' })
]
};
Advanced Configuration
For advanced users, you can customize the build process by modifying next.config.js
.