使用 Azure API 管理进行传递,但返回的 html 显示重定向。

问题描述 投票:0回答:1

我试图将我们的api管理后台从资源修改为webapp api.我采取了以下措施 将Azure Api管理用作通证 作为参考。

暴露的api是。https:/service -api -management.azure -api.netapi -nameoperation -name。

我想调用的实际api是。https:/service-name.azurewebsites.netapiSkillsAsyncoperation-name。

除了uri之外,请求主体和头部应该保持不变。所以我设置了下面的策略来改变uri。但响应是一个显示重定向的html。

我很好奇为什么它会返回一个显示重定向的html,以及我怎样才能使重定向正常工作。希望能得到任何意见。

政策。

<policies>
    <inbound>
        <base />
        <set-backend-service base-url="https://service-name.azurewebsites.net" />
        <rewrite-uri template="@(context.Request.Url.Path.Replace("/operation-name","/api/Skills/Async/operation-name"))" />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

回复:您好。

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
    <head>
        <title>Redirecting</title>
      ......
azure redirect azure-api-management api-management
1个回答
0
投票

测试并看看你的后端服务向Postman或Fiddler这样的工具返回什么,这些将是最好的模拟常规的HTTP请求,而不是由浏览器发送。也许后端希望在请求中隐含发送一些头,或者重定向只是非常快,用户无法察觉。为了让它通过APIM工作,你必须注意要么不触发重定向,要么让它再次重定向到APIM。在某种程度上,重定向-内容-url策略可能在这里有用。https:/docs.microsoft.comen-usazureapi-managementapi-management-transformation-policies#MaskURLSContent。

© www.soinside.com 2019 - 2024. All rights reserved.