When my angular SPA is served by node, I encounter an issue where upon refreshing or reloading a non-root page, the express-based server intercepts the route and returns "cannot GET route_X". What am I missing in my routes to allow for this refresh behavior?
angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/nests.html',
controller: 'NestController'
.when('/pair/:id', {
templateUrl: 'views/pairing.html',
controller: 'PairController'
})
.when('/pairs', {
templateUrl: 'views/pairs.html',
controller: 'PairListController'
});
$locationProvider.html5Mode(true);
}
]);
The only route defined in my express server is...
app.get('/', function(req, res) {
var html = fs.readFileSync('public/views/index.html', 'utf8');
res.send(html);
});
All other routing functionality is located in the index file.