node.jsazureurl-rewritingcors-anywhere

http or https in request path to a node server creates an error


I am trying to make corsanywhere work on Azure, and actually it works if I request something like this:

https://myserver.azurewebsites.net/www.remoteserver.com/query=john

But if I call this, I get a 500 error and I don't know how to track it (no error is produced in the logs in this case):

https://myserver.azurewebsites.net/http://www.remoteserver.com/query=john

This kind of request works well on the corsanywhere demo site or when I run my node app on my dev machine.

Update: Node on Azure needs a web.config file. Here is mine:

<configuration>
<system.webServer>
      <handlers>
        <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
        <rules>
          <rule name="DynamicContent">
             <match url="/*" />
             <action type="Rewrite" url="server.js"/>
          </rule>
        </rules>
      </rewrite>
</system.webServer>
</configuration>

I am wondering if this could be the culprit...

Thanks for your help


Solution

  • In Azure App Service (Windows OS), the characters :/ are not allowed in the URL path. This was discussed on SO before: Azure websites throw 500 error when there is a colon in the URL.

    You could try a solution in @TimBunting's answer, or host your application on a Linux App Service instead.