I'm building an Angular app served using Express on Node.
What I'd like to do is when the user visits the site, append their locale to the url (domain.com/en-gb).
Then regardless of what locale they have specified serve up the same index.html.
app.use('/', function(req, res) {
res.sendFile(__dirname + '/public/index.html');
});
The problem I'm having is working out how to serve up the same file regardless of request, but allowing assets such as images to not be rerouted to index.html as well?
Thanks, Harry
If you add a use
statement like the following one, you specify the location for your images:
var staticPathImages = __dirname + '/assets/images';
app.use(express.static(staticPathImages));
express will serve those static assets directly, without re-routing to index.html
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With