From b64491ecad75bd2b985edf2dc010ea088acfeeda Mon Sep 17 00:00:00 2001 From: Bent Cardan Date: Tue, 8 Oct 2013 04:02:08 -0400 Subject: [PATCH] let them bookmark and we preserve app state by the routeprovider url --- app.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index f9a67467c..8850554e1 100644 --- a/app.js +++ b/app.js @@ -26,6 +26,12 @@ app.use(express.methodOverride()); app.use(express.static(path.join(__dirname, 'public'))); app.use(app.router); +// middleware function puts hash before req.params +// redirect logic falls back to angular $routeProvider +app.use(function(req, res) { + return res.redirect(req.protocol + '://' + req.get('Host') + '/#' + req.url) +}); + // development only if (app.get('env') === 'development') { app.use(express.errorHandler()); @@ -48,9 +54,6 @@ app.get('/partials/:name', routes.partials); // JSON API app.get('/api/name', api.name); -// redirect all others to the index (HTML5 history) -app.get('*', routes.index); - /** * Start Server