Environment Detection
How it works
Section titled “How it works”The SDK automatically detects whether your application is running in a development or production environment. This affects middleware error verbosity only — development shows extra fields (suggestion, fix_command), production shows minimal errors.
Detection rules
Section titled “Detection rules”The environment is determined from the Host request header:
| Hostname | Environment |
|---|---|
localhost | development |
127.0.0.1 | development |
::1 | development |
*.local | development |
| Everything else | production (safe default) |
Override
Section titled “Override”You can override auto-detection in the Rakomi constructor:
const ca = new RakomiClient({ apiKey: 'akm_live_xxx', environment: 'development', // Always verbose errors});const ca = new RakomiClient({ apiKey: 'akm_live_xxx', environment: 'production', // Always minimal errors});Safe default
Section titled “Safe default”When the environment cannot be determined (e.g., missing Host header), the SDK defaults to production. This ensures sensitive error details are never accidentally exposed.
What changes by environment
Section titled “What changes by environment”| Field | Development | Production |
|---|---|---|
code | Included | Included |
message | Included | Included |
docs_url | Included | Included |
suggestion | Included | Omitted |
fix_command | Included | Omitted |