diff --git a/api/src/app.ts b/api/src/app.ts index bba8eaa761..27a36f2ed2 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -110,7 +110,14 @@ export default async function createApp() { html = html.replace(/href="\//g, `href="${publicUrl}`); html = html.replace(/src="\//g, `src="${publicUrl}`); - app.get('/', (req, res) => res.redirect(`./admin/`)); + app.get('/', (req, res, next) => { + if (env.ROOT_REDIRECT) { + res.redirect(env.ROOT_REDIRECT); + } else { + next(); + } + }); + app.get('/admin', (req, res) => res.send(html)); app.use('/admin', express.static(path.join(adminPath, '..'))); app.use('/admin/*', (req, res) => { diff --git a/api/src/env.ts b/api/src/env.ts index 8280d767b1..e044eff4a4 100644 --- a/api/src/env.ts +++ b/api/src/env.ts @@ -35,6 +35,8 @@ const defaults: Record = { REFRESH_TOKEN_COOKIE_SECURE: false, REFRESH_TOKEN_COOKIE_SAME_SITE: 'lax', + ROOT_REDIRECT: './admin', + CORS_ENABLED: true, CORS_ORIGIN: true, CORS_METHODS: 'GET,POST,PATCH,DELETE', diff --git a/docs/reference/environment-variables.md b/docs/reference/environment-variables.md index cc20caf196..8feeab2488 100644 --- a/docs/reference/environment-variables.md +++ b/docs/reference/environment-variables.md @@ -7,14 +7,15 @@ ## General -| Variable | Description | Default Value | -| ------------------ | --------------------------------------------------------------------------------------------------- | ------------- | -| `CONFIG_PATH` | Where your config file is located. See [Config Files](/reference/config-files/) | `.env` | -| `PORT` | What port to run the API under. | `8055` | -| `PUBLIC_URL` | URL where your API can be reached on the web. | `/` | -| `LOG_LEVEL` | What level of detail to log. One of `fatal`, `error`, `warn`, `info`, `debug`, `trace` or `silent`. | `info` | -| `LOG_STYLE` | Render the logs human readable (pretty) or as JSON. One of `pretty`, `raw`. | `pretty` | -| `MAX_PAYLOAD_SIZE` | Controls the maximum request body size. Accepts number of bytes, or human readable string. | `100kb` | +| Variable | Description | Default Value | +| ------------------ | ---------------------------------------------------------------------------------------------------------- | ------------- | +| `CONFIG_PATH` | Where your config file is located. See [Config Files](/reference/config-files/) | `.env` | +| `PORT` | What port to run the API under. | `8055` | +| `PUBLIC_URL` | URL where your API can be reached on the web. | `/` | +| `LOG_LEVEL` | What level of detail to log. One of `fatal`, `error`, `warn`, `info`, `debug`, `trace` or `silent`. | `info` | +| `LOG_STYLE` | Render the logs human readable (pretty) or as JSON. One of `pretty`, `raw`. | `pretty` | +| `MAX_PAYLOAD_SIZE` | Controls the maximum request body size. Accepts number of bytes, or human readable string. | `100kb` | +| `ROOT_REDIRECT` | Where to redirect to when navigating to `/`. Accepts a relative path, absolute URL, or `false` to disable. | `./admin` | ## Database