# Router

Settings for static HTTP routes.

## Configuration

{% tabs %}
{% tab title="JSON" %}

```
{
   "router": {
      "blocked_prefixes": [
         "/api"
      ],
      "routes": {},
      "ui_path": ""
   }
}
```

{% endtab %}

{% tab title="ENV" %}

```
CORE_ROUTER_BLOCKED_PREFIXES="/api"
CORE_ROUTER_ROUTES=
CORE_ROUTER_UI_PATH=
```

{% endtab %}
{% endtabs %}

### blocked\_prefixes (array)

List of path prefixes that are not allowed to be overwritten by a static route. If a static route would overwrite one of the blocked prefixes, an error will be thrown at startup. For the environment variable, provide a comma-separated list of prefixes, e.g. `/prefix1,/prefix2`.

By default this value is set to `["/api"]`.

### routes (map)

A list of static routes. This maps a path to a different path and results in a HTTP redirect, e.g. `{"/foo.txt": "/bar.txt"}` will redirect requests from `/foo.txt` to `/bar.txt`. Path have to start with a `/` and they are based on [storage.disk.dir](https://docs.datarhei.com/core/configuration/storage) on the filesystem.

The special suffix `/*` of a route allows you to serve whole directories from another root than storage.disk.dir, e.g. `{"/ui/*", "/path/to/ui"}`. If you use a relative path as target, then it will be added to the current working directory.

By default no routes are defined.

### ui\_path (string)

A path to a directory holding UI files. This will be mounted as `/ui`.

By default this value is not set, i.e. an empty string.
