Last active
April 21, 2016 14:26
-
-
Save clarkbw/93bcbbc13bad80eb472a to your computer and use it in GitHub Desktop.
html5mode with strongloop loopback and angularjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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