consider the following Node.js code:
var http = require('http');
var port = process.env.port || 1337;
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port);
It does not work in Microsoft Azure, because of string value in process.env.port variable (for example: \.\pipe\e289ed7e-b57b-46bb-8bba-ad8cd1f1529cf). Why is it happening?
The only thing should be done is to have a proper web.config file, for handling the named pipe port in Microsoft Azure. The simplest content for this file can be:
<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>
if your initial NodeJS file is app.js, replace the server.js strings in above content with it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With