express - Nuxt.js routes returning 404 in IIS with IISNODE -
just trying host nuxt.js , express.js demo in iis iisnode. getting 404's nuxt page routes, express api routes working fine.
all nuxt express handle routes. not sure why not working.
i have set web.config iisnode handler , have included url rewrite config route 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 , 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 in dev mode if (config.dev) { nuxt.build().catch(function (error) { console.error(error); // eslint-disable-line no-console process.exit(1); }); } // listen 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 requests 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 , subdirectories serving iis since these implementation details of node.js applications --> <security> <requestfiltering> <hiddensegments> <add segment="node_modules" /> </hiddensegments> </requestfiltering> </security> </system.webserver> </configuration>
iis node uses named pipes, therefore server render api calls on locahost tcp port 80 failing... server-side needs full url work.
Comments
Post a Comment