For BrowserSync (as described in @Bryandh) you need to configure it so that it always returns to your index.html . Depending on your project, you may have some task file (for example, the Gulp serve task, which is used throughout Aurelia) that needs to be changed.
As an example, I took the Aurelia skeleton navigation project. It has a skeleton-esnext subdirectory that uses Gulp and JSPM to run the application. There is a serve task in the build/tasks/serve.js file that needs to be configured as follows:
var historyFallback = require('connect-history-api-fallback'); gulp.task('serve', ['build'], function(done) { browserSync({ online: false, open: false, port: 9000, server: { baseDir: ['.'], middleware: [function(req, res, next) { res.setHeader('Access-Control-Allow-Origin', '*'); next(); }, historyFallback()] } }, done); });
An important part is the historyFallback() middleware. This is automatically provided by BrowserSync. If now you serve an application with this task ( gulp serve or gulp watch ), you can directly access your routes, for example. http://localhost:9000/users . There will no longer be 404, since you are in index.html , which loads Aurelia and processes the /users route.
source share