Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support environment variable placeholders in configuration files

Đang mở
#1,667 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi việc tải cấu hình cho devproxyrc.json và các tệp cấu hình plugin, sau đó đọc ProxyUtils.ReplaceVariables, IProxyConfiguration.Env và đường dẫn thay thế hiện có của MinimalPermissionsPlugin. Xác minh cách các giá trị môi trường và phần cấu hình env được biểu diễn trước khi quyết định việc phân giải nên nằm ở đâu. Hoàn tất khi các placeholder ${VAR_NAME} được phân giải nhất quán trong các tệp cấu hình được nêu mà không cần một script viết lại, với việc bao phủ các placeholder được nhúng như issuer URL.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

needs peer review

Summary

Dev Proxy config files (devproxyrc.json and plugin config files like CrudApiPlugin API files) don't support environment variable placeholders. This means values that vary per environment — like Entra app client IDs or tenant IDs — must be hardcoded in config files, or users need to write scripts to patch them before running Dev Proxy.

Example: the workaround today

In the da-ristorante-api-devproxy-entra sample, we need to inject ENTRA_APP_CLIENT_ID and ENTRA_APP_TENANT_ID into the CrudApiPlugin API files. Because Dev Proxy doesn't support this, the sample includes a Node.js script that reads .env.local and rewrites the JSON config files before each run.

The config file looks like this:

{
  "entraAuthConfig": {
    "audience": "<ENTRA_APP_CLIENT_ID>",
    "issuer": "https://login.microsoftonline.com/<ENTRA_APP_TENANT_ID>/v2.0"
  }
}

And the script manually replaces those placeholders with values from env files. This works but adds friction — extra tooling, an extra build step, and mutated config files that can accidentally get committed.

What I'd like to see

Support for environment variable references in config files, for example:

{
  "entraAuthConfig": {
    "audience": "${ENTRA_APP_CLIENT_ID}",
    "issuer": "https://login.microsoftonline.com/${ENTRA_APP_TENANT_ID}/v2.0"
  }
}

When Dev Proxy loads a config file, it would resolve ${VAR_NAME} placeholders against environment variables (or the env config section).

Why this seems feasible

Dev Proxy already has closely related infrastructure:

  • Path tokens: ~appFolder and ~dataFolder are resolved via ProxyUtils.ReplacePathTokens when loading config/plugin paths
  • @dynamic tokens: used in mock responses and rate limiting headers, resolved at runtime
  • ProxyUtils.ReplaceVariables: a general-purpose string replacement utility that replaces variable references in a string given a dictionary of values
  • IProxyConfiguration.Env: the proxy configuration already exposes a Dictionary<string, string> Env property
  • MinimalPermissionsPlugin already uses ProxyUtils.ReplaceVariables(fileContents, ProxyConfiguration.Env, v => $"{{{v}}}") to resolve {VAR} placeholders in OpenAPI spec files

The pattern is already proven in plugins — it just needs to be applied when loading configuration files too.

Benefits

  • No more wrapper scripts to inject environment-specific values
  • Config files stay clean and committable (no secrets, no environment-specific values)
  • Consistent with how other tools handle this (Docker Compose, Azure Pipelines, GitHub Actions, etc.)
  • Works naturally with .env files and CI/CD environments
Ngôn ngữ chính
C#
Star
832
Fork
90
Merge trung bình
18 giờ 41 phút
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/dev-proxy

Tất cả issue của dotnet/dev-proxy

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.