Fix server.js to route requests only once to a handler

See commit comment