add routing for external .js clients
updated error handling