Skip to content

Support response headers via environment variable with proper casing #319

@aram356

Description

@aram356

Problem

The [response_headers] config supports setting custom HTTP response headers via TOML, but setting them via environment variables loses header name casing and hyphens.

For example, TRUSTED_SERVER__RESPONSE_HEADERS__X_ROBOTS_TAG="noindex" results in the header key x_robots_tag instead of X-Robots-Tag, because the config crate lowercases env var names and can't represent hyphens.

Solution

Support a JSON object string as the env var value:

TRUSTED_SERVER__RESPONSE_HEADERS='{"X-Robots-Tag": "noindex", "X-Custom-Header": "custom value"}'

This preserves exact header name casing and hyphens. The existing TOML [response_headers] table format continues to work unchanged.

Acceptance Criteria

  • Custom deserializer handles both TOML table and JSON string inputs
  • Header names preserve casing and hyphens when set via env var
  • Existing TOML-based config is unaffected
  • Test coverage for JSON env var override
  • Documentation updated

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions