iisnode and express
Problem
I'm sure this question has been asked a million times but I've not found any Solution to the following problem as of yet.
I have a basic Application running using nodejs and express. When I run the application in node, it by default sends me to the index.html in my public folder. Even if I don't have any routes set up. I want this to happen.
I've installed Iisnode and created a new application under 'Default Website' called 'Devices'. I put my application in there unchanged. Reading around I needed to sort some stuff out with the web.config and decided to go with the config mentioned here (not the yaml):
http://tomasz.janczuk.org/2012/05/yaml-configuration-support-in-iisnode.html
When I try and load the app up in my browser it always tries to find the route in my app.js and throws messages back at me such as:
Cannot GET /devices/
I'm really pulling my hair out with this one and don't know what to do! Do I have to set up a default route for static content inside of my app.js entry point? I have the following in place:
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
But it still doesn't hand me over to index.html when I load the application from it's root:
'http://localhost/devices/'
Anyone able to help me out with this?
Solution
A good suggestion can be found at: Can an iisnode-hosted web application work out the virtual path at which it is hosted? Essentially, you use one small variable to abstract the path and an environment variable (if it exists) to control it. Another good post (possibly better solution) can be found at https://github.com/tjanczuk/iisnode/issues/160
Discussion
View additional discussion.