I create a project from the project template: "Basic Azure Node.js Express 4 Application
" in Visual Studio 2017 Enterprise edition.
When I run it locally it works fine.
Now I publish this to Azure using the below Publish
menu:
I get the following error:
iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error
I'm making no changes to the code from the template.
Any Ideas?
I followed your steps in Visual Studio 2017 Community edition. When I published the Express app to Azure Web App, I get the following error on my browser.
The page cannot be displayed because an internal server error has occurred.
After some investigation, I fixed it by changing the Web.config
file to something like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug" />
<handlers>
<add name="iisnode" path="bin/www" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^bin/www\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="bin/www" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Also, the web.config
file can be found at https://github.com/projectkudu/kudu/wiki/Using-a-custom-web.config-for-Node-apps.
Hope this will help you.