2023-12-12 18:36:07 +00:00
---
title: 'Configuration'
---
2023-12-31 14:39:55 +00:00
2023-12-12 18:25:35 +00:00
# Backend Config Reference
2023-12-31 14:39:55 +00:00
The backend can be configured in 3 different ways:
2023-12-12 20:44:28 +00:00
- Make a `config.json` file in the working directory of the application (root of repository)
- Make a `.env` file in the working directory of the application (root of repository)
- Add environment variables to your system (or container)
2023-12-31 14:39:55 +00:00
These different config options are all mutually inclusive, so you can use multiple at the same time if you want to.
::alert{type="warning"}
With any of these configurations, you have to have atleast three variables set for the server to function:
[`postgres.connection` ](#postgresconnection ), [`crypto.sessionSecret` ](#cryptosessionsecret ) and [`meta.name` ](#metaname )
::
### Method 1 - `config.json`
This method uses nesting, so the key `server.basePath` with the value of `"/backend"` will result in a file that looks like this:
2023-12-12 20:44:28 +00:00
```json
{
2023-12-31 14:39:55 +00:00
"server": {
"basePath": "/backend"
}
2023-12-12 20:44:28 +00:00
}
```
2023-12-31 14:39:55 +00:00
### Method 2 - `.env`
2023-12-12 20:44:28 +00:00
2023-12-21 18:42:08 +00:00
The environment variable names use double underscores as separators and `MWB_` as the prefix. So the key `server.basePath` will result in the .env file like this:
2023-12-31 14:39:55 +00:00
2023-12-12 20:44:28 +00:00
```sh
2023-12-21 18:42:08 +00:00
MWB_SERVER__BASE_PATH=/backend
2023-12-12 20:44:28 +00:00
```
2023-12-31 14:39:55 +00:00
### Method 3 - Environment
2023-12-12 20:44:28 +00:00
2023-12-21 18:19:45 +00:00
This method is identical to the `.env` method listed above, but you add the variables to the environment instead of writing it in a file.
2023-12-12 20:44:28 +00:00
# Reference
2023-12-31 14:39:55 +00:00
## Server
All configurations related to the HTTP server.
2023-12-12 20:44:28 +00:00
### `server.port`
2023-12-31 14:39:55 +00:00
- Type: `number`
- Default: `8080`
Port number that the HTTP server listens on.
2023-12-12 20:44:28 +00:00
### `server.cors`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `""`
- Example: `"https://movie-web.app https://testing.movie-web.app"`
2024-03-06 10:09:53 +00:00
Space separated list of allowed origins.
2023-12-12 20:44:28 +00:00
### `server.allowAnySite`
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
If set to true, it allows any origin to access the site. This overwrites the [`server.cors` ](#servercors ) setting.
2023-12-12 20:44:28 +00:00
### `server.trustProxy`
2023-12-21 20:25:14 +00:00
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
Controls whether the server should trust reverse proxy headers. This is used to identify users for ratelimiting.
2023-12-21 20:25:14 +00:00
### `server.trustCloudflare`
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
Controls whether the server should trust Cloudflare IP headers. This is used to identify users for ratelimiting.
2023-12-12 20:44:28 +00:00
### `server.basePath`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `"/"`
Prefix for which path is being listened on. Useful if you're hosting on `example.com/backend` for example.
::alert{type="info"}
If this is set, you shouldn't apply URL rewriting before proxying.
::
## Logging
All configurations related to how the HTTP server will log. This is not related to the [metrics ](0.introduction.md#metrics ) endpoint.
2023-12-12 20:44:28 +00:00
### `logging.format`
2023-12-31 15:01:56 +00:00
- Type: `string` | `"pretty"` | `"json"`
2023-12-31 14:39:55 +00:00
- Default: `"pretty"`
Logging format to use, should be either `pretty` or `json` , most users should probably use the default.
## Postgres
All configurations related to how postgres functions.
### `postgres.connection` ⚠
- Type: `string`
- Example: `"postgresql://localhost:5432"`
2023-12-12 20:44:28 +00:00
Connection URL for postgres instance, should contain the database in the URL.
2023-12-31 14:39:55 +00:00
::alert{type="danger"}
**Required. The backend will not start if this is not configured.**
::
2023-12-12 20:44:28 +00:00
### `postgres.migrateOnBoot`
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
Run all [migrations ](0.introduction.md#migrations ) that haven't ran yet on boot.
::alert{type="warning"}
2023-12-12 20:44:28 +00:00
If you have multiple replicas running, this can cause a lot of issues. We recommend only using this if you run only one replica.
::
### `postgres.debugLogging`
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
Log all postgres queries in the console. Useful for debugging issues with the database.
::alert{type="warning"}
This outputs sensitive, **DO NOT** run it in production.
::
2024-01-02 02:13:28 +00:00
### `postgres.ssl`
- Type: `boolean`
- Default: `false`
Enable SSL for postgres connections. Useful if you're using a hosted postgres database.
2023-12-31 14:39:55 +00:00
## Cryptography
All configurations related to cryptography.
### `crypto.sessionSecret` ⚠
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
- Type: `string`
The secret used to sign sessions. **Must be at least 32 characters long.**
::alert{type="danger"}
**Required. The backend will not start if this is not configured.**
::
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
## Meta
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
These options configure how the server will display itself to the frontend.
### `meta.name` ⚠
- Type: `string`
- Example: `"Unofficial movie-web"`
2023-12-12 20:44:28 +00:00
The name of the backend instance, this will be displayed to users who try to create an account.
2023-12-31 14:39:55 +00:00
::alert{type="danger"}
**Required. The backend will not start if this is not configured.**
::
2023-12-12 20:44:28 +00:00
### `meta.description`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `""`
- Example: `"This is not an official instance of movie-web"`
2023-12-12 20:44:28 +00:00
The description of the backend instance, this will be displayed to users who try to create an account.
2023-12-31 14:39:55 +00:00
## Captcha
All configurations related to adding captcha functionality. Captchas' help to protect your server from bot attacks.
2023-12-12 20:44:28 +00:00
### `captcha.enabled`
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
Enables [Recaptcha ](https://www.google.com/recaptcha/about/ ) support for user registration and login. [You can follow this guide to create a Recaptcha key ](https://cloud.google.com/recaptcha-enterprise/docs/create-key-website#create-key ){target="\_blank"}.
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
::alert{type="warning"}
If this is enabled, all other captcha related settings are required.
::
2023-12-12 20:44:28 +00:00
### `captcha.secret`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `""`
- Example: `"sjgaJ@3djasFVx"`
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
[Google Recaptcha ](https://www.google.com/recaptcha/about/ ) secret key.
2023-12-12 20:44:28 +00:00
### `captcha.clientKey`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `""`
- Example: `"2jf853z5bc63bvDb2323FAda"`
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
[Google Recaptcha ](https://www.google.com/recaptcha/about/ ) site key.
## Ratelimits
All configuration options related to adding ratelimiting functionality. Helps to protect against bot attacks or spammy users.
::alert{type="info"}
Make sure your IP headers are properly forwarded if you're using a reverse proxy. Also see [`server.trustProxy` ](#servertrustproxy ).
::
2023-12-12 20:44:28 +00:00
### `ratelimits.enabled`
2023-12-31 14:39:55 +00:00
- Type: `boolean`
- Default: `false`
Enables ratelimiting some more expensive endpoints.
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
::alert{type="warning"}
If this is enabled, all other ratelimit related settings are required.
::
2023-12-12 20:44:28 +00:00
### `ratelimits.redisUrl`
2023-12-31 14:39:55 +00:00
- Type: `string`
- Default: `""`
- Example: `"redis://localhost:6379"`
2023-12-12 20:44:28 +00:00
2023-12-31 14:39:55 +00:00
Redis connection URL for storing ratelimit data. You can use a plain redis instance for this, no modules are required.