在 Azure APIM 响应中更改 Set-Cookie 路径

Change Set-Cookie Path in Azure APIM response

我一直在尝试更改我的 Azure APIM API 响应的 cookie 路径。来自 APIM 的响应看起来像这样 Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly。我检查了可用的转换策略 here,但仍未找到解决方案。

我没有运行这个,但这通常应该有效:

<policies>
    <inbound>
        <base />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <set-header name="Set-Cookie" exists-action="override">
            <value>@{
               var cookie = context.Response.Headers.GetValueOrDefault("Set-Cookie","");
               return cookie.Replace("path=/;", "path=/myNewPath;");
            }
            </value>
        </set-header>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>