Skip to content

Commit c9a712b

Browse files
committed
adjust server
1 parent 64a61ee commit c9a712b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

server/server.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ app.use(
4949
})
5050
);
5151

52+
//if in production mode, statically serve everything in the build folder on the route '/dist'
53+
if (process.env.NODE_ENV == 'production') {
54+
console.log('in production');
55+
console.log('joined path: ', path.join(__dirname, '../build'));
56+
app.use('/', express.static(path.join(__dirname, '../build')));
57+
} else {
58+
console.log('not production');
59+
console.log('joined path: ', path.join(__dirname, '../build'));
60+
app.get('/', (req, res) => {
61+
const indexPath = path.join(__dirname, '../index.html');
62+
return res.status(200).sendFile(indexPath);
63+
});
64+
}
65+
5266
// NOTE from v13.0 team: GitHub OAuth works fine in Electron production app and the backend for Electron production app is deployed on Heroku at https://reactype-caret.herokuapp.com/ (get credentials from instructor )
5367

5468
const passport = require('passport');
@@ -523,20 +537,6 @@ app.get(
523537
// const isDocker = process.env.IS_DOCKER === 'true';
524538
// console.log('this is running on docker: ', isDocker);
525539

526-
//if in production mode, statically serve everything in the build folder on the route '/dist'
527-
if (process.env.NODE_ENV == 'production') {
528-
console.log('in production');
529-
console.log('joined path: ', path.join(__dirname, '../build'));
530-
app.use('/', express.static(path.join(__dirname, '../build')));
531-
} else {
532-
console.log('not production');
533-
console.log('joined path: ', path.join(__dirname, '../build'));
534-
app.get('/', (req, res) => {
535-
const indexPath = path.join(__dirname, '../index.html');
536-
return res.status(200).sendFile(indexPath);
537-
});
538-
}
539-
540540
// app.get('/bundle.js', (req, res) => {
541541
// return res.status(200).sendFile(path.join(process.cwd(), 'bundle.js'));
542542
// });

0 commit comments

Comments
 (0)