Skip to content

Environment Detection

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.

The environment is determined from the Host request header:

HostnameEnvironment
localhostdevelopment
127.0.0.1development
::1development
*.localdevelopment
Everything elseproduction (safe default)

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
});

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.

FieldDevelopmentProduction
codeIncludedIncluded
messageIncludedIncluded
docs_urlIncludedIncluded
suggestionIncludedOmitted
fix_commandIncludedOmitted