-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node scripts/heroku-start.js |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// https://medium.com/captainme-ai/deploying-migrating-static-create-react-app-project-to-heroku-22-stack-b19a4255ea7c | ||
|
||
const express = require('express'); | ||
const path = require('path'); | ||
const app = express(); | ||
const port = process.env.PORT || 3000; | ||
|
||
app.use(express.json()); | ||
|
||
// Your static pre-build assets folder | ||
app.use(express.static(path.join(__dirname, '..', 'build'))); | ||
|
||
// Root Redirects to the pre-build assets | ||
app.get('/', function(req, res) { | ||
res.sendFile(path.join(__dirname, '..', 'build')); | ||
}); | ||
|
||
// Any Page Redirects to the pre-build assets folder index.html that // will load the react app | ||
app.get('*', function(req, res){ | ||
res.sendFile(path.join(__dirname, '..', 'build/index.html')); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log("Server is running on port: ", port) | ||
}) |
This file contains 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