mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 15:47:48 +01:00
deploying to heroku
This commit is contained in:
9
app.js
9
app.js
@@ -21,10 +21,6 @@ const passport = require('./config/passport');
|
||||
|
||||
app.use(passport.initialize());
|
||||
|
||||
if (process.env.NODE_ENV === 'prod') {
|
||||
app.use(express.static(path.join(__dirname, 'react/build')));
|
||||
}
|
||||
|
||||
app.use('/api/users', require('./routes/users'));
|
||||
|
||||
const auth = require('./routes/auth');
|
||||
@@ -32,6 +28,11 @@ const auth = require('./routes/auth');
|
||||
app.use('/api/lists', auth.required, require('./routes/lists'));
|
||||
app.use('/api/todos', auth.required, require('./routes/todos'));
|
||||
|
||||
if (process.env.NODE_ENV === 'prod') {
|
||||
app.use(express.static(path.join(__dirname, 'react/build')));
|
||||
app.use('*', express.static(path.join(__dirname, 'react/build/index.html')));
|
||||
}
|
||||
|
||||
// 404 route
|
||||
app.use((req, res) => {
|
||||
res.status(404);
|
||||
|
||||
@@ -2,17 +2,17 @@ const env = process.env.NODE_ENV;
|
||||
|
||||
const prod = {
|
||||
app: {
|
||||
port: process.env.APP_PORT,
|
||||
port: process.env.PORT,
|
||||
},
|
||||
db: {
|
||||
uri: process.env.DB_URI,
|
||||
uri: process.env.DB_URI || process.env.MONGODB_URI,
|
||||
},
|
||||
secret: process.env.SECRET,
|
||||
};
|
||||
|
||||
const dev = {
|
||||
app: {
|
||||
port: process.env.DEV_APP_PORT || 4000,
|
||||
port: process.env.DEV_PORT || 4000,
|
||||
},
|
||||
db: {
|
||||
uri: process.env.DEV_DB_URI || 'mongodb://localhost/todolist',
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"scripts": {
|
||||
"start": "node ./app.js",
|
||||
"debug": "cross-env NODE_ENV=dev npx nodemon --inspect ./app.js",
|
||||
"test": "cross-env NODE_ENV=test jest"
|
||||
"test": "cross-env NODE_ENV=test jest",
|
||||
"heroku-postbuild": "cd react && npm i && npm run build"
|
||||
},
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user