Where they live
Local .env.local, and Railway variables named in .railway/ with preserve() so values stay out of git.
A config secret has two homes in the tree this pass read. Commands below are copied from infra/README.md. They were not run.
- Local dev. A
.env.localfile in the repo root, which you create and which git ignores. - Staging and production. Railway holds the values.
.railway/variables.tsand.railway/environments.tsname the variables.preserve()keeps a secret's current Railway value, so the value is not in git.
infra/staging/ and infra/prod/ contain railway.yaml and a Centrifugo JSON file. They do not contain secrets.staging.yaml or secrets.prod.yaml. scripts/sync-railway-env.sh is not in the repository at a5dff0c208d5193c274d3d1f87787b55344d5d30. Do not follow an older page that tells you to edit those YAML files or run that script.
Re-read at API fbb63d5178bcfe171292daebb19b6cbdac025a44 on 14 November 2026. infra/staging/ lists centrifugo.staging.json and railway.yaml. infra/prod/ lists centrifugo.prod.json and railway.yaml. Neither directory has a secrets yaml. The comment in docker-compose.dev.yaml on the Centrifugo service says Railway-dynamic values, the redis address, are layered as env vars from infra/<env>/secrets.<env>.yaml. That path is a name in a comment. It is not a file, and this page does not invent a hosted Redis URL from it. The committed placeholders are local only. .env.example sets REDIS_URL to redis://localhost:6379 and CACHE_REDIS_URL to redis://localhost:6379/1. docker-compose.yaml sets REDIS_URL to redis://redis:6379 for the server, worker, and audit services. Those are the compose network and a laptop. They are not a staging or production address.
.env.local
When the app boots, NestJS's ConfigModule is told to load from .env.local.
ConfigModule.forRoot({
isGlobal: true,
load: [config],
envFilePath: '.env.local',
}),That populates process.env before the Zod schema validates it. (apps/server/src/instrument.ts is imported first in main.ts and starts OpenTelemetry before any module loads.) Copy .env.example to .env.local (Task env does this when the file is missing) and replace placeholders with values a teammate hands you. Do not commit .env.local.
.env.example is a template, not a secret store
.env.example is committed and lists key names. It is not a reason to paste real values into git. envSchema remains the boot check. A blank entry is an empty string and overrides a Zod default. Where the example and the schema disagree, trust the schema and fix the example in the same change.
Railway variables
toEnv in .railway/variables.ts builds a service's variable map from one or more groups. A group has settings (the value is written in the file) and secrets (only the name is listed).
secrets.map((name) => [name, preserve()] as const)The comment above Vars says a service's variables are exactly what its groups list, and anything missing is deleted on apply. preserve() keeps the value Railway already holds.
APP.secrets names the shared secrets for the API, worker, and audit apps, including DATABASE_URL, JWT_SECRET_KEY, REDIS_URL, and RABBIT_MQ_URL. At API main 6bfb9f6bdb004fd3a909405c2c826cf1e383249b, the same tree as staging 0d611c96, that array names OPENAI_API_KEY and does not name OPENROUTER_API_KEY. Compare d229592a...6bfb9f6b does not touch the array. .env.example has no blank line for it either. The live value was not read. Deployment was not verified. GitHub Actions run 45252018549 finished apply-production: Plan and Apply both succeeded, and apply-staging was skipped. The logs were not opened, so this page does not say a worker restarted. This page does not copy the full list or any setting value. Open the file. Some non-secret settings are committed there too, such as JWT_ACCESS_TOKEN_EXPIRATION_MS. That is configuration, not a licence to commit a credential. See Authentication.
infra/README.md is the procedure:
- Set the secret in Railway first, in the dashboard or with
railway variable set NAME --stdin -s <service> -e <environment>. - Add the name to the right
secretsarray. - Apply through
.github/workflows/railway-config.yml.
A pull request into staging that touches .railway/** gets a plan comment. Merging applies that pinned plan to Staging. A push to main that touches .railway/** plans and applies to production through the prod GitHub Environment. This audit did not watch either apply.
infra/staging/railway.yaml and infra/prod/railway.yaml are still in the tree. They are target IDs for scripts/redeploy-railway-services.sh, not a secrets file. The Taskfile task is redeploy-railway. It was not run. See Getting Started.
Service links use Railway reference strings in settings, for example the Centrifugo URL built from RAILWAY_PRIVATE_DOMAIN. The secret value itself stays in Railway.
Where to go next
Adding and rotating
Declare a key, set it in Railway, then name it with preserve().
Secrets at Rest
The product secrets that live in the database, not these env files.
Config & Environment
How the shaped config is consumed through ConfigService.
Secrets and credentials
Back to the overview and the key-name inventory.
Sources
Naalya-APIinfra/README.md,infra/staging/andinfra/prod/directory listings,.railway/variables.tstoEnv,preserve,APP- Absence of
scripts/sync-railway-env.shand ofsecrets.*.yamlata5dff0c208d5193c274d3d1f87787b55344d5d30 - Re-read at
fbb63d5178bcfe171292daebb19b6cbdac025a44:infra/staging/andinfra/prod/listings,docker-compose.dev.yamlCentrifugo comment,docker-compose.yamlREDIS_URL,.env.exampleREDIS_URLandCACHE_REDIS_URL OPENROUTER_API_KEYis absent fromAPP.secretsand from.env.exampleatmain6bfb9f6bdb004fd3a909405c2c826cf1e383249b, the same tree as staging0d611c96. Compared229592a...6bfb9f6bdoes not touch those files. A search of the tree finds noOPENROUTER_API_KEY. The Railway value was not read. GitHub Actions run 45252018549 finishedapply-productionfor the earlier commita888ae35, before this key returned. The logs were not opened. Deployment was not verified.
Secrets and credentials
How the API handles secrets, the key names that matter, the Zod fail-fast boundary, and the one rule that keeps real values out of git.
Secrets at rest
The product side, API keys hashed with SHA-256 and shown once, the Microsoft clientState secret, and the /docs Basic Auth gate.