I have an Azure function written in NodeJS where I am trying to call an HTTP redirect from 302. The documentation is very sparse regarding valid entries in the response. As a result, I created an object with what, in my opinion, should be correct in order to generate a redirect, but all I get is an XML response. Even elements, such as a status code, are displayed in XML, and do not change the actual status code.
What am I doing wrong?
My code is:
module.exports = function(context, req){ var url = "https://www.google.com"; context.res = { status: 302, headers: { Location: url } } context.done(); }
This is the answer I get in the browser:
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 1164 Content-Type: application/xml; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Wed, 18 Jan 2017 00:54:20 GMT Connection: close <ArrayOfKeyValueOfstringanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><KeyValueOfstringanyType><Key>status</Key><Value xmlns:d3p1="http://www.w3.org/2001/XMLSchema" i:type="d3p1:int">302</Value></KeyValueOfstringanyType><KeyValueOfstringanyType><Key>headers</Key><Value i:type="ArrayOfKeyValueOfstringanyType"><KeyValueOfstringanyType><Key>Location</Key><Value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" i:type="d5p1:string">https://www.google.com</Value></KeyValueOfstringanyType></Value></KeyValueOfstringanyType></ArrayOfKeyValueOfstringanyType>
source share