Skip to content

Environment Variables ​

The backend reads its configuration from backend/.env (loaded with dotenv). This page lists every variable, its default, whether it is required, and what it does.

The list is derived from backend/.env.example and from every process.env.* read in backend/src. Where the code and the example differ, the difference is called out in the description.

Complete reference ​

VariableDefaultRequiredDescription
NODE_ENVdevelopmentNoRuntime mode. development enables SQL query logging in Sequelize; use production on a server.
PORT3001NoHTTP port the Express API listens on.
DB_HOSTlocalhostYesMySQL/MariaDB hostname.
DB_PORT3306NoMySQL/MariaDB port.
DB_NAMEtele_storage_dbYesDatabase name (the value comes from .env.example; the code reads it directly).
DB_USERrootYesDatabase user.
DB_PASSWORD(empty)ConditionalDatabase password. May be empty for a passwordless local database; required when your DB user has a password.
JWT_SECRET(none)YesSigns access tokens. Must be at least 32 characters and not a placeholder. Validated at boot.
JWT_EXPIRE15mNoAccess-token lifetime.
REFRESH_TOKEN_SECRET(none)YesSigns refresh tokens. At least 32 characters, not a placeholder. Validated at boot.
REFRESH_TOKEN_EXPIRE7dNoRefresh-token lifetime.
FILE_ACCESS_TOKEN_EXPIRE5mNoLifetime of signed preview/download URLs. Used in jwt.service.js.
ENCRYPTION_KEY(none)YesEncrypts per-user Telegram credentials at rest and optional file encryption. At least 32 characters, not a placeholder. Validated at boot. Keep it stable.
TELEGRAM_BOT_TOKEN(none)Dev onlyFallback bot token used only when NODE_ENV is not production, for local development and testing. Not a production multi-user fallback.
TELEGRAM_STORAGE_CHAT_ID(none)Dev onlyFallback storage channel ID used only when NODE_ENV is not production.
TELEGRAM_API_URLhttps://api.telegram.org/bot<token>NoNot read by the code. Present in .env.example for a future public or local Bot API server, but the backend calls https://api.telegram.org directly (hardcoded in telegram-storage.service.js), so setting this has no effect.
TELEGRAM_API_SERVER_URLhttp://localhost:8081NoNot read by the code. Present in .env.example only; setting it has no effect.
REDIS_HOSTlocalhostNoNot read by the code. Teldock has no Redis dependency and no preview queue; previews are generated in-process (see backend/src/routes/preview.routes.js). Setting this has no effect.
REDIS_PORT6379NoNot read by the code. Present in .env.example only; setting it has no effect.
CORS_ORIGINhttp://localhost:3000NoAllowed browser origin. Must match the frontend origin exactly; set it explicitly in production.
BCRYPT_ROUNDS12NoPassword-hashing cost factor. Read by backend/src/config/security.js; values outside 4–15 fall back to 12 with a warning.
TG_PART_SIZE18874368 (~18 MB)NoBytes per chunk when uploading to Telegram. Used in telegram-storage.service.js.
MAX_UPLOAD_BYTES2147483648 (2 GB)NoMaximum accepted upload size. Used by the HTTP and WebDAV upload paths.
WEBDAV_RATE_LIMIT_MAX5000NoRequests allowed per 15 minutes on the /webdav router. Failed authentication attempts are limited separately to 20 per 15 minutes.
FRONTEND_URLhttp://localhost:3000NoBase URL used to build absolute share short links (for example <FRONTEND_URL>/s/<token>). Read in SharedLink, share.controller.js and file-management.service.js. Set it to your public frontend origin in production; without it, share links are returned as relative paths.

Example .env ​

ini
# Server
NODE_ENV=development
PORT=3001
CORS_ORIGIN=http://localhost:3000
FRONTEND_URL=http://localhost:3000

# Database
DB_HOST=localhost
DB_PORT=3306
DB_NAME=tele_storage_db
DB_USER=root
DB_PASSWORD=

# Authentication secrets (required — the server refuses to boot with placeholders)
JWT_SECRET=<generate-random-secret>
JWT_EXPIRE=15m
REFRESH_TOKEN_SECRET=<generate-random-secret>
REFRESH_TOKEN_EXPIRE=7d
FILE_ACCESS_TOKEN_EXPIRE=5m

# Encryption (required, keep stable)
ENCRYPTION_KEY=<generate-random-secret>

# Telegram (local dev/testing only — production users connect their own bot in Settings)
TELEGRAM_BOT_TOKEN=
TELEGRAM_STORAGE_CHAT_ID=

# Storage / uploads
TG_PART_SIZE=18874368
MAX_UPLOAD_BYTES=2147483648
WEBDAV_RATE_LIMIT_MAX=5000

# Security
BCRYPT_ROUNDS=12

Generate the three secrets with:

bash
node -e "console.log(require('crypto').randomBytes(48).toString('hex'))"

Required in production ​

Strictly required

JWT_SECRET, REFRESH_TOKEN_SECRET and ENCRYPTION_KEY are mandatory. The backend validates them at startup and exits if they are missing, shorter than 32 characters, or still set to an example placeholder. See backend/src/config/secrets.js.

The database connection variables (DB_HOST, DB_NAME, DB_USER, and DB_PASSWORD when applicable) must point at a reachable database. CORS_ORIGIN should be set to your real frontend origin in production rather than left at the localhost default.

Optional in all environments:

  • BCRYPT_ROUNDS — password-hashing cost factor (4–15; defaults to 12).
  • TELEGRAM_BOT_TOKEN / TELEGRAM_STORAGE_CHAT_ID — development/testing fallbacks only.

The following variables appear in backend/.env.example but are not read by the code, so they have no effect and can be omitted: TELEGRAM_API_URL, TELEGRAM_API_SERVER_URL, REDIS_HOST, REDIS_PORT.

See also ​

Released under the MIT License.