Last active
April 10, 2018 17:25
-
-
Save mbenedettini/950ebe05cb278efe67a2ed7b53c3eefa to your computer and use it in GitHub Desktop.
loopback angular html5 mode
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
/* | |
I usually insert this snippet right at the beginning of server.js | |
*/ | |
const path = require('path'); | |
const staticRoot = path.resolve(__dirname, '..', 'client-dist'); | |
app.all('/*', function(req, res, next) { | |
if (req.url.startsWith('/api')) { | |
return next(); | |
} | |
if (req.url.startsWith('/agendash')) { | |
return next(); | |
} | |
let asset = | |
req.url.match(/\/(assets\/.*)/) || | |
req.url.match(/\/(.*\.(js|css|map|png|svg|jpg|xlsx))\??/); | |
if (asset) { | |
return res.sendFile(asset[1], {root: staticRoot }); | |
} | |
// Just send the index.html for other files to support HTML5Mode | |
res.sendFile('index.html', { root: staticRoot }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment