Skip to main content
The application configuration is defined in the config/ directory and loaded using the @feathersjs/configuration package. Configuration files are loaded based on the NODE_ENV environment variable.

Configuration Files

Feathers applications use the following configuration structure:
  • config/default.json - Default configuration for all environments
  • config/production.json - Production-specific overrides
  • config/test.json - Test environment configuration
  • config/custom-environment-variables.json - Maps environment variables to configuration

Configuration Schema

When generating a new application with schemas enabled, Feathers creates a configuration schema that validates your application settings.

Core Settings

string
required
The hostname the server should bind to.Default: localhostEnvironment Variable: HOSTNAME
number
required
The port number the server should listen on.Default: 3030Environment Variable: PORT
string
required
The path to the public directory for serving static files.Default: ./public/
string[]
An array of allowed CORS origins. Used for cross-origin requests.Default: ['http://localhost:3030']

Pagination Settings

object
Default pagination settings for database queries.

Example Configuration

Usage

The configuration is automatically loaded and applied to your application:
src/app.ts

Validation

When using schemas, configuration is validated during application setup. Invalid configuration will throw an error before the application starts:
src/app.ts

Environment Variables

Map environment variables to configuration values using config/custom-environment-variables.json:
The __format option converts the environment variable to the specified type. Supported formats include:
  • number - Parse as number
  • json - Parse as JSON
  • boolean - Parse as boolean

Best Practices

Keep environment-specific settings in separate files (production.json, staging.json, etc.) rather than in default.json.
Store sensitive values like API keys and secrets in environment variables, not in configuration files. Use custom-environment-variables.json to map them.
Always use configuration schemas to catch errors early and ensure your application has valid settings.
Add comments to your configuration schema to document what each setting does and its valid values.