is probably the most popular web framework for Node.js and tons of tutorials and instructions have already been written. However, most of them don't cover the topic I am going to tell you about. Express A standard approach to routing that is seen across various docs looks like this: app = express(); app.get( , { res.send( ); }); var '/' ( ) function req, res 'Hello World!' or this: router = express.Router(); router.get( , { res.send( ); }); ... app.use( , router); var '/' ( ) function req, res 'Hello from foo' '/foo' So your routing structure probably looks somewhat similar to the picture below This works perfectly in your local development environment. However, in real-world there might be a small problem. An actual catalogue for your application on hosting platform might be other than the domain root. For example, you deploy the application containing routes above to the . Now if you open in the browser you probably expect it to show . But instead, you get a 404 error. In order to receive an expected greeting, you should have written the route like this: yourdomain.com/hello yourdomain.com/hello 'Hello World' app.get( , { res.send( ); }); '/hello' ( ) function req, res 'Hello World!' The same can be said about the router's subpath. A proper way to receive from would be: 'Hello from foo' yourdomain.com/hello/foo app.use( , router); '/hello/foo' While it is not hard to rewrite paths in a small application, trying to do it in a large app with lots of routes (especially poorly structured) can become a nightmare. In addition what if you want to change a directory later? Starting rewriting all over again, in that case, is a bad idea. A better option is to make the only point for routing and make this path configurable. entry entry First, create a to store the project-level variables config.js .exports = { : , } //config.js module baseUrl '/' Then you should reorganize routes structure so that the or router includes all other routes while its own path would be taken from entry index config.js config = ( ); app = express(); indexRouter = express.Router(); indexRouter.get( , { res.send( ); }); fooRouter = express.Router(); fooRouter.get( , { res.send( ); }); indexRouter.use( , fooRouter); app.use(config.baseUrl, indexRouter); const require './config.js' var var '/' ( ) function req, res 'Hello World!' var '/' ( ) function req, res 'Hello from foo' '/foo' Basically what we did was transforming previous structure to this That's it. Now if you deploy your application to a subfolder, for example, `yourdomain.com/hello`, change the config.js to .exports = { : , } //config.js module baseUrl '/hello/' and all routes would be updated automatically. If an application is deployed straight to root, just leave as it is. yourdomain.com baseUrl: '/' I hope the described lifehack will help you to organize routes in Express app a way better. Credits Train photo by from Paul IJsendoorn Pexels