Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
TEIIDTOOLS-341: Ensure routes in address bar are handled correctly
Browse files Browse the repository at this point in the history
* Ensure that Angular, rather than Express, handle manually entered paths
  in browser address bar.
  • Loading branch information
phantomjinx committed Apr 17, 2018
1 parent 825547b commit 13a1f49
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ngapp/server.js
Expand Up @@ -6,8 +6,24 @@ app.use(bodyParser.json());

// Create link to Angular build directory
var distDir = __dirname + "/dist/";

//
// Serves all the dist directory as a web application
//
app.use(express.static(distDir));

//
// Catch-all route that ensures any paths added to the host
// in the address bar, eg. example.com/dataservices, are passed
// on to the angular app to handle.
//
// Ensures that manually entered addresses are handled by
// angular and express remains a simple passthrough.
//
app.get('*', function (req, res) {
res.sendFile(distDir + '/index.html');
});

// Initialize the app.
var server = app.listen(process.env.PORT || 8080, function () {
var port = server.address().port;
Expand Down

0 comments on commit 13a1f49

Please sign in to comment.