The main configurations of the project are located in the `./config` directory. Additional configs can be added in the `./api/**/config` folder of each API and plugin by creating JavaScript or JSON files.
The `./config/functions/` folder contains a set of JavaScript files in order to add dynamic and logic based configurations.
All functions that are exposed in this folder are accessible via `strapi.config.functions['fileName']();`
### Bootstrap
**Path —** `./config/functions/bootstrap.js`.
The `bootstrap` function is called at every server start. You can use it to add a specific logic at this moment of your server's lifecycle.
Here are some use cases:
- Create an admin user if there isn't one.
- Fill the database with some necessary data.
- Load some environment variables.
The bootstrap function can be synchronous or asynchronous.
**Synchronous**
```js
module.exports = () => {
// some sync code
};
```
**Return a promise**
```js
module.exports = () => {
return new Promise(/* some code */);
};
```
**Asynchronous**
```js
module.exports = async () => {
await someSetup();
};
```
### CRON tasks
CRON tasks allow you to schedule jobs (arbitrary functions) for execution at specific dates, with optional recurrence rules. It only uses a single timer at any given time (rather than reevaluating upcoming jobs every second/minute).
This feature is powered by [`node-schedule`](https://www.npmjs.com/package/node-schedule) node modules. Check it for more information.
Most of the application's configurations are defined by environment. It means that you can specify settings for each environment (`development`, `production`, `test`, etc.).
To start your application in production environement you will have to specify `NODE_ENV=production`.
::: tip
You can access the config of the current environment through `strapi.config.currentEnvironment`.
-`debug` (boolean): Show database exchanges and errors.
-`autoMigration` (boolean): To disable auto tables/columns creation for SQL database.
-`pool` Options used for database connection pooling. For more information look at [Knex's pool config documentation](https://knexjs.org/#Installation-pooling).
-`min` (integer): Minimum number of connections to keep in the pool. Default value: `0`.
-`max` (integer): Maximum number of connections to keep in the pool. Default value: `10`.
-`acquireTimeoutMillis` (integer): Maximum time in milliseconds to wait for acquiring a connection from the pool. Default value: `2000` (2 seconds).
-`createTimeoutMillis` (integer): Maximum time in milliseconds to wait for creating a connection to be added to the pool. Default value: `2000` (2 seconds).
-`idleTimeoutMillis` (integer): Number of milliseconds to wait before destroying idle connections. Default value: `30000` (30 seconds).
-`reapIntervalMillis` (integer): How often to check for idle connections in milliseconds. Default value: `1000` (1 second).
-`createRetryIntervalMillis` (integer): How long to idle after a failed create before trying again in milliseconds. Default value: `200`.
-`expose` (array): Configures the `Access-Control-Expose-Headers` CORS header. If not specified, no custom headers are exposed. Default value: `["WWW-Authenticate", "Server-Authorization"]`.
-`maxAge` (integer): Configures the `Access-Control-Max-Age` CORS header. Default value: `31536000`.
-`credentials` (boolean): Configures the `Access-Control-Allow-Credentials` CORS header. Default value: `true`.
-`methods` (array)|String - Configures the `Access-Control-Allow-Methods` CORS header. Default value: `["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]`.
-`headers` (array): Configures the `Access-Control-Allow-Headers` CORS header. If not specified, defaults to reflecting the headers specified in the request's Access-Control-Request-Headers header. Default value: `["Content-Type", "Authorization", "X-Frame-Options"]`.
-`ip`
-`enabled` (boolean): Enable or disable IP blocker. Default value: `false`.
-`port` (integer): Port on which the server should be running. Default value: `1337`.
-`emitErrors` (boolean): Enable errors to be emitted to `koa` when they happen in order to attach custom logic or use error reporting services.
-`proxy`
-`enabled` (boolean): Enable proxy support such as Apache or Nginx. Default value: `false`.
-`ssl` (boolean): Enable proxy SSL support.
-`host` (string): Host name your proxy service uses for Strapi.
-`port` (integer): Port that your proxy service accepts connections on.
- [`cron`](https://en.wikipedia.org/wiki/Cron)
-`enabled` (boolean): Enable or disable CRON tasks to schedule jobs at specific dates. Default value: `false`.
-`admin`
-`autoOpen` (boolean): Enable or disabled administration opening on start. Default value: `true`.
-`path` (string): Allow to change the URL to access the admin panel. Default value: `/admin`.
-`watchIgnoreFiles` (array): Add custom files that should not be watched during development. See more [here](https://github.com/paulmillr/chokidar#path-filtering) (property `ignored`). Default value: `[]`.
-`build`
-`backend` (string): URL that the admin panel and plugins will request (default: `http://localhost:1337`).
As an example using this configuration with Nginx your server would respond to `https://example.com:8443` instead of `http://localhost:1337`.
**Note:** you will need to configure Nginx or Apache as a proxy before configuring this example.
```json
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": true,
"ssl": true,
"host": "example.com",
"port": 8443
},
"cron": {
"enabled": true
}
}
```
## Dynamic configurations
For security reasons, sometimes it's better to set variables through the server environment. It's also useful to push dynamic values into configuration files. To enable this feature in JSON files, Strapi embraces a JSON-file interpreter into its core to allow dynamic values in the JSON configuration files.
### Syntax
The syntax is inspired by the [template literals ES2015 specifications](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). These dynamic values are indicated by the Dollar sign and curly braces (`${expression}`).
### Usage
In any JSON configuration file in your project, you can inject dynamic values like this:
-`environment` (string): Sets the environment you want to store the data in. By default it's current environment (can be an empty string if your config is environment agnostic).
-`type` (string): Sets if your config is for an `api`, `plugin` or `core`. By default it's `core`.
-`name` (string): You have to set the plugin or api name if `type` is `api` or `plugin`.
-`key` (string, required): The name of the key you want to store.