6

I've written a website in node.js and express. Now I configured lighttpd to use the node.js server with an subdirectory:

$HTTP["url"] =~ "^/app/" {
  proxy.server  = ( "" => ( (
                              "host" => "127.0.0.1",
                              "port" => 3000
                            ) )
                  )
}

When I open http://localhost/app/ I get error 404 because I wrote something like this:

app.get('/', function (req, res){
  res.render('index');
});

Is there a better way as modifying these lines like:

var relPath = '/app';

app.get(relPath + '/', function (req, res){
  res.render('index');
});

?

ChristophLSA
  • 175
  • 3
  • 19

1 Answers1

4

As Ryan commented the solution is:

app.use('/app', app.router);

If you use e.g. express.static or express.favicon you have to tell app.use the path also:

app.use('/app', express.favicon(__dirname + '/public/images/favicon.ico'));
app.use('/app', express.static(__dirname + '/public'));

Remember to write '/app' before each internal link you set in your html.

ChristophLSA
  • 175
  • 3
  • 19