1
votes

Just trying to host the nuxt.js and express.js demo in iis with iisnode. I am getting 404's for the nuxt page routes, but the express api routes are working fine.

All that nuxt does is all express to handle its routes. Not sure why this is not working.

I have set up my web.config with iisnode handler and I have also included the url rewrite config to route everything to the server.prod.js

'use strict';

var Nuxt = require('nuxt');
var app = require('express')();
var host = process.env.HOST || '127.0.0.1';
var port = process.env.PORT || 3000;

app.set('port', port);
// Import API Routes
app.use('/api', require('./api/index'));

// Import and Set Nuxt.js options
var config = require('./nuxt.config.js');
config.dev = !(process.env.NODE_ENV === 'production');

// Init Nuxt.js
var nuxt = new Nuxt(config);
app.use(nuxt.render);

// Build only in dev mode
if (config.dev) {
  nuxt.build().catch(function (error) {
    console.error(error); // eslint-disable-line no-console
    process.exit(1);
  });
}

// Listen the server
app.listen(port, host);
console.log('Server listening on ' + host + ':' + port); // eslint-disable-line no-console
<configuration>
<system.webServer>
   <handlers><add name="iisnode" path="server.prod.js" verb="*" modules="iisnode" /></handlers>  
    <rewrite>
      <rules>
        <rule name="myapp">
          <match url="/*" />
          <action type="Rewrite" url="server.prod.js" />
        </rule>
        <!-- Don't interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>

      </rules>

    </rewrite>
        <directoryBrowse enabled="true" />

        <iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="true" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />

     <!-- exclude node_modules directory and subdirectories from serving
     by IIS since these are implementation details of node.js applications -->

     <security>
       <requestFiltering>
         <hiddenSegments>
           <add segment="node_modules" />
         </hiddenSegments>
       </requestFiltering>
     </security>    

 </system.webServer>
</configuration>
1
I can further say that dynamic routes below the top level work. that is i have subdirectory routes /myDir/_cat/_subcat/_page.vue and this seems to work fineShay

1 Answers

1
votes

IIS Node uses named pipes, therefore the server render api calls on locahost tcp port 80 were failing... The server-side needs a full url to work.