node.jsangularexpressangular-universal

Deploy Angular Universal to IIS


I am having a problem deploying my Node.js to the IIS, in my web.config:

> <handlers>
>         <add name="iisnode-ng-universal" path="dist/server.js" verb="*" modules="iisnode" />
>     </handlers>

 <rule name="ng-universal" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{HTTP_HOST}" pattern="test" />
        </conditions>
        <action type="Rewrite" url="dist/server.js" />
    </rule>

I am getting this error:

enter image description here

This how my web files tree looks:

web files

I tried to give full permission to IIS_IUSRS and IUSR but it does not seem to work. Like this post suggested: iisnode encountered an error when processing the request


Solution

  • can you try the below code.. it works for me

    <?xml version="1.0" encoding="utf-8"?>
    
    
    <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>
    

    Your server.js can be outside the dist folder.