# Settings of a website - SSR websites

> Every setting of site.config.ts of an SSR website - title, domains, auth providers, default access, the tables ctx.db reaches with their row rules, ctx.api, ctx.sys, ctx.fetch, cache, CSP and headers, SEO, redirects, trailing slashes, maintenance and limits.

Source: https://docs.apimaker.dev/v4/docs/ssr/site-config.html

`site.config.ts` gives the settings of a website **as values** : the server reads them when the file is saved, and decides with them before any code of a page runs. Code there (a function, a variable) is a problem the panel shows : the settings it can read are kept.

**site.config.ts**

```ts
import { defineSite } from 'am-ssr';

export default defineSite({
    title: 'My shop',
    titleTemplate: '%s · My shop',
    description: 'Things for a calm home.',
    lang: 'en',
    domains: ['shop.example.com'],
    auth: { providers: ['customers'], loginPath: '/login', sessionDays: 30 },
    defaultAccess: 'public',
    data: {
        read: ['mongodb/shop/products', { table: 'mongodb/shop/orders', where: { customer_id: '$user._id' }, requireUser: true }],
        write: [{ table: 'mongodb/shop/orders', where: { customer_id: '$user._id' }, requireUser: true, allow: ['create'] }],
        apiUser: 'website',
        allowSys: false,
        fetch: ['api.stripe.com'],
    },
    cache: { maxAge: 0 },
    security: { csp: 'strict', frameAncestors: ["'self'"], headers: { 'x-powered-by': 'API Maker' } },
    seo: { sitemap: true, robots: 'allow', noIndex: false },
    redirects: [{ from: '/old-shop/*', to: '/products', status: 301 }],
    trailingSlash: 'never',
    maintenance: false,
    limits: { memoryMb: 64, cpuMs: 2000, timeoutMs: 30000 },
});
```

## Typed settings

`defineSite` takes a `SiteConfig` of `am-ssr` : in the editor of the panel, in VS Code and in WebStorm (the folder of the website in [git](https://docs.apimaker.dev/v4/docs/ssr/git.html)), every setting is completed with what it does, its default and the values the server takes, and a mistake is marked before the file is saved — a setting of another name (`defaultAcess`), a table which is no `instance/database/table`, a `loginPath` or a redirect which is no path, a status or a word the server does not know.

**site.config.ts**

```ts
export default defineSite({
    data: {
        read: ['shop/products'],
        //     ~~~~~~~~~~~~~~~ a table is 'instance/database/table'
    },
    trailingSlash: 'sometimes',
    //             ~~~~~~~~~~~ 'never', 'always' or 'ignore'
});
```

| Setting | Its type |
|---|---|
| the whole | `SiteConfig` |
| `auth` | `SiteAuth` |
| `defaultAccess` | `SiteAccess` : the values of `access` without code (`check` is for pages) |
| `data` | `SiteData`, its tables `TableName` or `TableRule`, `allow` a list of `TableWrite` |
| `cache` | `CacheConfig`, as a page has it |
| `security` | `SiteSecurity` |
| `seo` | `SiteSeo` |
| `redirects` | a list of `SiteRedirect` |
| `maintenance` | `true`, or a `SiteMaintenance` |
| `limits` | `SiteLimits` |

The server reads the file itself when it is saved, and tells what it can not read as a problem of the website : a file which TypeScript does not check (an editor of your own without the declarations) is checked all the same.

## Every setting

| Setting | Default | What it is |
|---|---|---|
| `title` | the title of the website in the panel | The title of a page which has none, and `ctx.site.title`. |
| `titleTemplate` | | Around the title of a page : `'%s · My shop'`. |
| `description` | | The description of a page which has none. |
| `lang` | `'en'` | The language of the pages. |
| `domains` | `[]` | Hosts a reverse proxy serves the website at, at their root : for their requests, addresses are written without `/ssr/<apiPath>/<name>`. See [deployment](https://docs.apimaker.dev/v4/docs/ssr/deployment.html). |
| `auth.providers` | `[]` | The auth providers of the account the visitors sign in with. See [authentication](https://docs.apimaker.dev/v4/docs/ssr/authentication.html). |
| `auth.loginPath` | | Where a visitor who is not signed in goes for a page which asks for one (`?next=` added). Without it, such a visitor gets the page of the error `401`. |
| `auth.sessionDays` | `7` | How long a session lasts, 1 to 365. |
| `defaultAccess` | `'public'` | Who may open a page which says nothing : `'public'`, `'authenticated'`, `{ groups }`, `{ providers }`. |
| `data.read` | `[]` | The tables `ctx.db` reads, each a name (`'instance/database/table'`) or a rule. See [data](https://docs.apimaker.dev/v4/docs/ssr/data.html#ctxdb-the-tables-a-website-lists). |
| `data.write` | `[]` | The tables `ctx.db` writes, with `allow` to keep a table to some writes. |
| `data.apiUser` | | The API user whose groups the calls of `ctx.api` carry, by its user name. |
| `data.allowSys` | `false` | Turns `ctx.sys` on : everything the account may do. |
| `data.fetch` | `[]` | The hosts `ctx.fetch` may ask : `'api.stripe.com'`, `'*.example.com'`. |
| `cache` | none | How long the pages which say nothing are kept. See [caching](https://docs.apimaker.dev/v4/docs/ssr/caching.html). |
| `security.csp` | `'strict'` | `'strict'`, `'relaxed'`, `'off'`, or a policy of your own (`{nonce}` is the nonce of the answer). See [security](https://docs.apimaker.dev/v4/docs/ssr/security.html#csp). |
| `security.frameAncestors` | `["'self'"]` | Who may show the pages in a frame. |
| `security.headers` | `{}` | Headers of every answer. The ones the server writes itself (cookies, length, type, location) are not taken. |
| `seo.sitemap` | `true` | `/sitemap.xml`. |
| `seo.robots` | `'allow'` | `/robots.txt` : `'allow'`, `'disallow'`, or its text. |
| `seo.noIndex` | `false` | No page is indexed. |
| `redirects` | `[]` | `{ from, to, status }` : `from` a path (`/old/*` for every path below it), `to` a path of the website or an address, `status` 301, 302, 307 or 308 (308). |
| `trailingSlash` | `'never'` | `/about/` goes to `/about` (`'never'`), `/about` to `/about/` (`'always'`), or both answer (`'ignore'`). |
| `maintenance` | `false` | `true`, or `{ message, allowGroups }` : the website answers `503` with the message, but to the groups which may see it. |
| `limits.memoryMb` | `ssr.memoryMb` of the server | The memory of an engine of the website, 8 to 1024. |
| `limits.cpuMs` | `ssr.cpuMs` | The time the code of one render may run, 10 to 60000. |
| `limits.timeoutMs` | `ssr.timeoutMs` | The time of one render in all, the waits for data included, 100 to 600000. |

## Problems

What can not be read is a problem of the file `site.config.ts`, which the panel shows (the button with the count of problems) with its words : `data.read[1] : 'shop/products' : a table is named 'instance/database/table'`. The website runs with the settings it read, and the defaults of the others — but a mistake never opens more : a `defaultAccess` which can not be read closes the pages which say nothing, an `access` of a page which can not be read closes that page, and rules of `data` which can not be read reach no table, until they are right.
