1

I am trying to deploy my NuxtJS application on a new IIS server. I have installed latest Node and IISNode. Below are my web.config and server/index.js. Site Binding is on localhost:93 but I keep getting error - 'This page isn't working' http error 500. Appreciate your help.

web.config

<!--
    This configuration file is required if iisnode is used to run node processes behind
    IIS or IIS Express.  For more information, visit:

    https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
 <system.webServer>
   <!-- Visit https://azure.microsoft.com/en-us/blog/introduction-to-websockets-on-windows-azure-web-sites/ for more information on WebSocket support -->
   <webSocket enabled="false" />
   <handlers>
     <!-- Indicates that the server.js file is a Node.js site to be handled by the iisnode module -->
     <add name="iisnode" path="server" verb="*" modules="iisnode"/>
   </handlers>
   <rewrite>
     <rules>
       <!-- Do not interfere with requests for node-inspector debugging -->
       <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
         <match url="^server\/debug[\/]?" />
       </rule>

       <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
       <rule name="StaticContent">
         <action type="Rewrite" url="public{REQUEST_URI}"/>
       </rule>

       <!-- All other URLs are mapped to the Node.js site entry point -->
       <rule name="DynamicContent">
         <conditions>
           <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
         </conditions>
         <action type="Rewrite" url="server" />
       </rule>
     </rules>
   </rewrite>

   <!-- 'bin' directory has no special meaning in Node.js and apps can be placed in it -->
   <security>
     <requestFiltering>
       <hiddenSegments>
         <remove segment="bin"/>
         <add segment="node_modules" />
       </hiddenSegments>
     </requestFiltering>
   </security>

   <!-- Make sure error responses are left untouched -->
   <httpErrors existingResponse="PassThrough" />
   <iisnode node_env="production" />
   <!--
     You can control how Node is hosted within IIS using the following options:
       * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
       * node_env: will be propagated to node as NODE_ENV environment variable
       * debuggingEnabled - controls whether the built-in debugger is enabled

     See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
   -->
   <!--<iisnode watchedFiles="web.config;*.js"/>-->
 </system.webServer>
</configuration>

server/index.js

const express = require('express');
const consola = require('consola');
const { Nuxt, Builder } = require('nuxt');
const app = express();

const config = require('../nuxt.config.js');
config.dev = process.env.NODE_ENV !== 'production';

async function start() {
  const nuxt = new Nuxt(config);
  const { host, port } = nuxt.options.server;

  if (config.dev) {
    const builder = new Builder(nuxt);
    await builder.build();
  } else {
    await nuxt.ready();
  }

  app.use(nuxt.render);

  app.listen(port, host);
  consola.ready({
    message: `Server listening on http://${host}:${port}`,
    badge: true
  });
}

start();

This is the error SS:

enter image description here

Saad Momin
  • 97
  • 1
  • 6
  • Could you please use "[Failed Request Tracing Rules](https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr)" to trace the logs of 500 error ? – Hury Shen Jul 15 '21 at 05:19
  • 1
    Sorry I just cloned by previous server to resolve this. Crunch of time. Apologies. I guess we will never know why – Saad Momin Jul 16 '21 at 06:43

0 Answers0