From 8b100ea94ecc17b8afd3f602643b67aba412b76b Mon Sep 17 00:00:00 2001 From: florimondmanca <florimond.manca@gmail.com> Date: Sat, 17 Mar 2018 19:34:49 +0000 Subject: [PATCH] fix cannot GET/ on page reload --- package-lock.json | 2 +- package.json | 6 +++--- server.js | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5ab66d5..6cf92fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2275,7 +2275,7 @@ "integrity": "sha1-WbTiqk8lQi9sY7UntGL14tDdLFg=", "requires": { "fs-extra": "0.23.1", - "handlebars": "~>4.0.0", + "handlebars": "1.3.0", "img-stats": "0.5.2" }, "dependencies": { diff --git a/package.json b/package.json index 505bbbe..890b643 100644 --- a/package.json +++ b/package.json @@ -9,21 +9,21 @@ "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", - "postinstall": "ng build --prod" + "heroku-postbuild": "ng build --prod" }, "private": true, "dependencies": { "@agm/core": "^1.0.0-beta.2", + "@angular/cli": "1.4.9", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", + "@angular/compiler-cli": "^4.4.6", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", - "@angular/cli": "1.4.9", - "@angular/compiler-cli": "^4.4.6", "core-js": "^2.4.1", "express": "^4.16.3", "fuse.js": "^3.2.0", diff --git a/server.js b/server.js index 413e472..baaf1fb 100644 --- a/server.js +++ b/server.js @@ -9,9 +9,14 @@ const app = express(); // Serve only the static files form the dist directory app.use(express.static(__dirname + '/dist')); +// Redirect all requests to Angular's index.html file +app.get('*', function(req, res) { + res.sendFile(__dirname + '/dist/index.html'); +}); + // Start the app by listening on the default Heroku port // (Heroku gives the app a port through the $PORT environment variable) // Use port 4200 by default -const port = process.env.PORT || 4200 +const port = process.env.PORT || 4200; app.listen(port); console.log(`Server listening on port ${port}`); -- GitLab