The app-server binary takes the following config options:
--config: path of the javascript file exporting the app-server config. Defaults toapp-server.config.js--root: root directory to serve. Defaults tobuild--fallbackAssetPath: absolute path (relative to the root directory) of the asset to use as fallback when requests don't match any other asset. The asset MUST exist. Defaults to/index.html--fallbackStatusCode: status code to use when serving the fallback asset. Defaults to200--headers: (asset matcher, headers) map specifying which headers to assign to which assets--configuration: JSON configuration object for the static app, i.e. what becomeswindow.APP_CONFIG--configurationKeyPrefix: Prefix of the environment variables used to generate the configuration for the static app. Defaults toAPP_CONFIG_--basePath: static app base path. Defaults to/--port: port to listen on. Defaults to3000
Options can also be passed via config file, a javascript file exporting an object defining one or more of the above config options. Example:
module.exports = {
fallbackAssetPath: "/not-found.html",
fallbackStatusCode: 404
};Options can also be passed as upper-cased, snake-cased, environment variables
prefixed by APP_SERVER_. Eg:
export APP_SERVER_FALLBACK_ASSET_PATH=...
export APP_SERVER_FALLBACK_STATUS_CODE=...Option sources have the following priority:
- command line flags
- environment variables
- options defined in the config file
Meaning for example that when an option is provided both as a command line flag and as an environment variable, the value provided with the command line flag is used.
The JSON configuration object that is injected by app-server into the served
static app (as the global variable window.APP_CONFIG) is generated by merging:
- the JSON object passed as the
--configurationoption - a JSON object generated from environment variables using the following
algorithm:
- filter variables whose name doesn't start with the prefix specified by the
--configurationKeyPrefixoption - strip the prefix from the name of the remaining variables
- create the object using those key-value pairs
- filter variables whose name doesn't start with the prefix specified by the
- the following variables automatically added by app-server:
BASE_PATH: the base path specified with the--basePathoption
Given the --configuration option:
{
"KEY_0": "OPT_VALUE_0",
"KEY_1": "OPT_VALUE_1"
}the --basePath option /, and given the environment:
APP_CONFIG_KEY_1=ENV_VALUE_1
APP_CONFIG_KEY_2=ENV_VALUE_2
NON_PREFIXED_KEY=VALUEthe following window.APP_CONFIG is generated:
window.APP_CONFIG = {
KEY_0: "OPT_VALUE_0",
KEY_1: "ENV_VALUE_1",
KEY_2: "ENV_VALUE_2",
BASE_PATH: "/"
};