Azure APIM Redirect URL

Ricardo Rosa 1 Reputation point
2021-11-24T14:41:40.933+00:00

Hello, I'll try to explain as best I can: I have an API management instance (https://my-apim.azure-api.net) with several API's. I need to implement a GET where APIM redirects to the login page (eg https://www.mywebsite.com/login ) if my APIM is called without the API suffix (eg "/login").

How would I do this?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,447 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-11-25T04:38:13.36+00:00

    @Ricardo Rosa You need to create a new API with the / API URL suffix so whenever someone is navigating to https://my-apim.azure-api.net this / API should be called.

    152367-image.png

    Once you have created the API now you need to add operation with the URL /

    152448-image.png

    Once your operation is created now you need to use the return-response policy for the redirection to your login page. If you already have another API created for the same then you can redirect to that API and modify it according to your need.

    152438-image.png

    <inbound>  
            <return-response>  
                <set-status code="303" reason="Redirecting" />  
                <set-header name="Location" exists-action="override">  
                    <value>@("https://google.com/")</value>  
                </set-header>  
            </return-response>  
            <base />  
        </inbound>  
    

    Note: You need to write before the base else your base policy would be executed first and it may cause an issue.

    Feel free to get back to me if you need any assistance.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.