Skip to content

Instantly share code, notes, and snippets.

@clarkbw
Last active April 21, 2016 14:26
Show Gist options
  • Save clarkbw/93bcbbc13bad80eb472a to your computer and use it in GitHub Desktop.
Save clarkbw/93bcbbc13bad80eb472a to your computer and use it in GitHub Desktop.
html5mode with strongloop loopback and angularjs
var loopback = require('loopback');
var boot = require('loopback-boot');
var path = require('path');
var app = module.exports = loopback();
// boot scripts mount components like REST API
boot(app, __dirname);
// https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
app.all('/*', function(req, res, next) {
// Just send the index.html for other files to support HTML5Mode
res.sendFile('index.html', { root: path.resolve(__dirname, '..', 'client') });
});
app.start = function() {
'use strict';
// start the web server
return app.listen(function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
});
};
// start the server if `$ node server.js`
if (require.main === module) {
app.start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment