Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support environment variable placeholders in configuration files

未关闭
#1,667 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp
领域
cli, tooling

调研方向

首先跟踪 devproxyrc.json 和插件配置文件的配置加载过程,然后阅读 ProxyUtils.ReplaceVariables、IProxyConfiguration.Env 以及 MinimalPermissionsPlugin 现有的替换路径。在决定应在哪里进行解析之前,确认环境值和 env 配置部分是如何表示的。完成标准是:在所示配置文件中一致地解析 ${VAR_NAME} 占位符,而不需要重写脚本,并覆盖 issuer URL 等嵌入式占位符。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
C#
星标
833
派生
90
平均合并
18 小时 41 分钟
30 天内合并 PR
45

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/dev-proxy 的其他 Issue

查看 dotnet/dev-proxy 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。