Reputation: 9870
Calls to APIM have suddenly started redirecting to the backend service.
In my test environments, I get a 301 Moved Permanently, whereas for the exact same code deployed to prod, I just get a 200.
Why is my APIM returning a 301?
Here's the HTTP request (the first request is the pre-flight request):
Here're the settings in APIM:
Upvotes: 0
Views: 2099
Reputation: 7810
The most probable case is that it's not APIM's fault at all, very likely 301 response is coming all the way from backend. You can use API inspector to make sure: https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-api-inspector
By default if backend replies to APIM with 301, APIM will simply return 301 to client as well. See that location header in response points to azurewebsites and not APIM.
You can either take a look at your backend and make it not return 301, or you can make APIM follow redirect response by the means of a policy: https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#ForwardRequest. The latter would be slower since APIM would need to make two calls to backend to get a proper response.
Upvotes: 1