[Fixed] Nuxt.js routes returning 404 in IIS with IISNODE


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 || '';
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);

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

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


        <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 -->

           <add segment="node_modules" />



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.

Leave a Reply

(*) Required, Your email will not be published