简体   繁体   English

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

[英]Change Set-Cookie Path in Azure APIM response

I have been trying to change the cookie path of my Azure APIM API response.我一直在尝试更改 Azure APIM API 响应的 cookie 路径。 The response from the APIM looks like this Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly来自 APIM 的响应类似于Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly . Set-Cookie: ssnid=2d4cfdd62638436481130eb0fad7a889; path=/; secure; HttpOnly I checked the transform policies available here but still haven't figured out a solution.我检查了此处可用的转换策略但仍未找到解决方案。

I haven't run this but this should generally work:我还没有运行过这个,但这通常应该有效:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM