# Production checklist

What to set and check before an app takes real traffic. Each item says what Hamur does without your help and links the page that has the key. The [self-hosting guide](/self-hosting) covers the image, the proxy and the stop.

## Secrets and sessions

- [ ] `HAMUR_KEY` is set in the environment of every instance, 32 bytes, and kept out of the image and the repository. A built server with a malformed key does not start, and one with no key throws `HAMUR_KEY is not set`. Keep the old key after a rotation: `HAMUR_KEY=<new>,<old>`. See [The app key](/sessions-and-security#the-app-key).
- [ ] Every variable the app reads is declared in `app/env.ts`, and the config reads a secret only through `env("NAME")` (a storage `url` or `encrypt`, `tasks.http.token`, a route rule's `basicAuth.password`, a module's credentials), never as a literal. A `HAMUR_<KEY>` variable named after a `runtimeConfig` key changes nothing; the variables Hamur reads itself are [listed](/environment#hamurs-own-variables). A misspelt name or a private entry under `runtimeConfig.public` fails the build, and a missing private value stops the server at start ([Environment](/environment#env-references-in-the-config)).
- [ ] While you rotate a session password, `useSession` gets the new one first and the old one after it ([Rotating the password](/sessions-and-security#rotating-the-password)).
- [ ] Form posts carry a `csrf()` token bound to the session ([CSRF](/sessions-and-security#csrf)).

## Headers, origin and CSP

- [ ] The three default headers are on (`nosniff`, `strict-origin-when-cross-origin`, `SAMEORIGIN`). Add `hsts` once every subdomain serves https ([Security defaults](/sessions-and-security#security-defaults), [Header keys](/sessions-and-security#header-keys)).
- [ ] The cross-origin form check is on (`server.originCheck`, on by default); list an identity provider's origin in `originCheck.allow` instead of turning it off ([Security defaults](/sessions-and-security#security-defaults)).
- [ ] `server.csp` is set. It is off by default; `mode: "auto"` writes a nonce or hashes for the scripts Hamur and your UI library inline ([Content Security Policy](/sessions-and-security#content-security-policy)). Turn on `csp.report` to see violations ([Violation reports](/sessions-and-security#violation-reports)).
- [ ] `server.trustProxy` is on behind a proxy, with `server.requestIP` for the client address, or `app.origin` pins the public origin ([Behind a proxy](/self-hosting#behind-a-proxy)).

## Build

- [ ] `build.sourcemap` is unset or `"none"` unless you mean to publish the client maps; a production build writes none by default ([`hamur` reference](/api-reference/hamur)).
- [ ] `server.compress` is on (the default) for `bun` and `node`, or the proxy compresses and you turned it off ([Compression](/deploy/presets/node#compression)).
- [ ] Pages that can be built ahead are prerendered ([Prerender](/route-rules#prerender)).
- [ ] The preset is named in the config or `HAMUR_PRESET`; the build log says which one it built ([Deploy](/deploy#choosing-a-preset)).

## Caches

- [ ] A cached answer is the anonymous answer: the handler runs on a cache fork without the cookie or `authorization`, so a page that depends on the user needs `varies` or no cache ([Route rules](/api-reference/storage-details#route-rules), [Opting a request out](/api-reference/server#nostore)).
- [ ] With more than one instance, `cache` is a shared driver ([Running several instances](/caching-and-isr#running-several-instances)).
- [ ] A handler's answer with a cookie, `private` or `no-store` is not stored; check a page that sets a cookie before you put a `cache` rule on it ([Checking and shaping entries](/api-reference/server#definecachedfunction-cachedfunctionoptions-cacheoptions-cacheentry)).

## Observability

- [ ] `server.health` is on and the proxy or orchestrator probes it ([Health endpoint](/observability#health-endpoint)).
- [ ] Logs go to a collector or to the host's log driver as JSON lines, the build's default; `server.logRedact` hides fields you must not keep ([Logging](/observability#logging)).
- [ ] `server.requestLog`, `server.tracing` and `server.metrics` are off in a build until you turn them on; a Prometheus scrape needs `HAMUR_METRICS_TOKEN` or `prometheus.token`, and `token: false` makes the endpoint public ([Prometheus](/observability#prometheus)) ([What is on by default](/observability#what-is-on-by-default), [Metrics](/observability#metrics)).
- [ ] Errors are reported with the `error` hook or `server.clientReports` ([Reporting errors](/observability#reporting-errors), [Client reports](/observability#client-reports)).

## Errors

- [ ] An error that is not a `createError` shows only its status text in production, and `data` is dropped; throw `createError` for what the visitor should read ([Where errors come from](/errors#where-errors-come-from)).
- [ ] An error page of your own is in place ([The error page](/errors#the-error-page), [Changing the error answer](/errors#changing-the-error-answer)).

## Run

- [ ] The image runs as built, with `HEALTHCHECK` and a stop grace period of 30 seconds ([Stopping](/self-hosting#stopping)).
- [ ] `hamur preview --check` passes on the build before you ship it ([`hamur preview --check`](/deploy/platforms/preview-check)).
