Universal Environment Configuration
Last updated
Last updated
From soya-next-scripts@0.3.0 and later, environment configuration is embedded during runtime. Therefore, every changes made in the configuration will take effect immediately after restarting the server. It's the opposite of the earlier version which is embedded during compile time and need to be rebuilt before the changes took effect.
Environtment configuration in Soya Next is configured using . To create one, you need to understand how it works first. By default, node-config will read all your configuration files defined in config
directory relative to your Soya Next project root. It will read your configuration files with the following order:
Where
EXT
can be yml
, yaml
, xml
, coffee
, cson
, properties
, json
, json5
, hjson
or js
depending on the format you prefer,
{short_hostname}
is your server name up to the first dot, from the HOST
or HOSTNAME
environment variable or os.hostname()
(in that order). For example if your hostname is www.example.com
then it would load www.EXT
.
{full_hostname}
is your whole server name, you may use this when {short_hostname}
collides with other machines.
{deployment}
is the deployment name, from the NODE_ENV
environment variable.
Suppose you have the following configuration at config/default.json
:
You can access the configuration values by looking at the example below.
The following are the configurations keys which are reserved:
assetPrefix
Type: string
Prefix added to assets. It will fallback to basePath
or basePath.test
.
basePath
Type: string
or { test: string, exclude: string|Array.<string> }
Base URL to which the app paths (assets, pages, static) are prefixed.
defaultLocale
Type: string
The default locale used when no locale segment found in the url.
routes
Type: Object.<Object>
Define custom routes.
redirects
Type: Object.<Object>
Redirect obsolete pages.
Redirect static routes
Redirect custom routes
siteLocales
Type: Array.<string>
All locales which is supported by your app.
server
Type: Object
Default: { "host": "0.0.0.0", "port": 3000 }
For security reasons, the configuration within server
won't get exposed/hydrated to the client. It should not be consumed by the client as well. So if you wanted to consume a secret, it'd be best to store it within server
and ensure it only got consumed by the server.
{instance}
is an optional instance name string for .
Please refer to this for the full documentation.
Please refer to this for the full documentation.