Skip to main content

Environment Variable Configuration

This document explains the main environment variables used by ABC User Feedback's API server and web server and how to configure them.


1. API Server Environment Variables

Required Environment Variables

Environment VariableDescriptionDefaultExample
JWT_SECRETSecret key for JWT signingNonejwtsecretjwtsecretjwtsecret
MYSQL_PRIMARY_URLMySQL connection URLNonemysql://user:pass@host:3306/db
ACCESS_TOKEN_EXPIRED_TIMEAccess Token validity period10m10m, 30s, 1h
REFRESH_TOKEN_EXPIRED_TIMERefresh Token validity period1h1h, 7d

JWT secret should be a sufficiently complex and secure string.

⚠️ Security Notes:

  • JWT_SECRET should be at least 32 characters long and complex
  • Never use default values in production environments
  • Do not include environment variable files (.env) in version control
  • Manage sensitive information through environment variables or secret management systems

Optional Environment Variables

Environment VariableDescriptionDefaultExample
APP_PORTAPI server port40004000
APP_ADDRESSBinding address0.0.0.0127.0.0.1
ADMIN_WEB_URLAdmin web URLhttp://localhost:3000https://admin.company.com
BASE_URLPublic API server URL used in Swagger documentationNonehttps://api.example.com
MYSQL_SECONDARY_URLSSecondary DB URLs (JSON array)None["mysql://..."]
AUTO_MIGRATIONAuto migration on app startuptruefalse
MASTER_API_KEYMaster permission API key (optional)Noneabc123xyz
NODE_OPTIONSNode execution optionsNone--max_old_space_size=4096

SMTP Settings (Email Authentication)

Environment VariableDescriptionExample
SMTP_HOSTSMTP server addresssmtp.gmail.com
SMTP_PORTPort (usually 587 or 465)587
SMTP_USERNAMELogin usernameuser@example.com
SMTP_PASSWORDLogin password or tokenapp-password
SMTP_SENDERSender addressnoreply@company.com
SMTP_BASE_URLBase URL for links in emailshttps://feedback.company.com
SMTP_TLSWhether to use TLStrue
SMTP_CIPHER_SPECEncryption specTLSv1.2
SMTP_OPPORTUNISTIC_TLSWhether to support STARTTLStrue

📎 For detailed settings, refer to the SMTP Integration Guide.


2. OpenSearch Settings (Optional)

Environment VariableDescriptionExample
OPENSEARCH_USEWhether to enable OpenSearchtrue
OPENSEARCH_NODEOpenSearch node URLhttp://localhost:9200
OPENSEARCH_USERNAMEAuthentication IDadmin
OPENSEARCH_PASSWORDAuthentication passwordadmin123

OpenSearch is used to improve search speed and AI features.


3. Automatic Feedback Deletion Settings

Environment VariableDescriptionDefault / Condition
AUTO_FEEDBACK_DELETION_ENABLEDEnable old feedback deletion featurefalse
AUTO_FEEDBACK_DELETION_PERIOD_DAYSDeletion criteria in days365 (required if enabled)

4. Web Server Environment Variables

Required Environment Variables

Environment VariableDescriptionExample
NEXT_PUBLIC_API_BASE_URLAPI server address for client usehttp://localhost:4000

Optional Environment Variables

Environment VariableDescriptionDefaultExample
PORTFrontend port30003000

5. Configuration Methods

Docker Compose Example

services:
api:
image: line/abc-user-feedback-api
environment:
- JWT_SECRET=changeme
- MYSQL_PRIMARY_URL=mysql://user:pass@mysql:3306/userfeedback
- SMTP_HOST=smtp.sendgrid.net
- SMTP_USERNAME=apikey
- SMTP_PASSWORD=your-sendgrid-key

.env File Example

# apps/api/.env
JWT_SECRET=changemechangemechangeme
MYSQL_PRIMARY_URL=mysql://root:pass@localhost:3306/db
ACCESS_TOKEN_EXPIRED_TIME=10m
REFRESH_TOKEN_EXPIRED_TIME=1h
SMTP_HOST=smtp.example.com
SMTP_SENDER=noreply@example.com
# BASE_URL=https://api.example.com # Set when serving behind a reverse proxy

# apps/web/.env
NEXT_PUBLIC_API_BASE_URL=http://localhost:4000

7. Troubleshooting Guide

ProblemCause and Solution
Environment variables not recognizedCheck .env location or restart container
DB connection failureCheck MYSQL_PRIMARY_URL format or connection info
SMTP errorRecheck port/TLS settings or authentication info
OpenSearch errorCheck node URL or user authentication
JWT token errorCheck JWT_SECRET length and complexity
Environment variable validation failureCheck for missing required variables or type errors
Port conflictCheck APP_PORT, PORT settings