Skip to content

Commit 79ac28f

Browse files
committed
Merge branch 'dev' into jon-chatUI
2 parents 7229185 + 5cca29a commit 79ac28f

File tree

6 files changed

+46
-35
lines changed

6 files changed

+46
-35
lines changed

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: node server/server.js
1+
web: npx tsx server/server.ts

app/src/public/styles/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
33
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
44
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0');
5-
@import url('https: //fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');
5+
/* @import url('https: //fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap'); */
66

77
*,
88
*::before,

app/src/serverConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const isProduction = process.env.NODE_ENV === 'production';
22
const serverConfig = {
33
DEV_PORT: 5656,
44
API_BASE_URL: isProduction
5-
? 'https://app.reactype.dev'
5+
? 'https://reactype-2c81e4204f81.herokuapp.com'
66
: 'http://localhost:5656',
77
// : 'http://localhost:8080',
88
API_BASE_URL2: isProduction
9-
? 'https://app.reactype.dev'
9+
? 'https://reactype-2c81e4204f81.herokuapp.com'
1010
: 'http://localhost:8080'
1111
};
1212
// module.exports = config;

config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const isProduction = process.env.NODE_ENV === 'production';
22
const config = {
33
DEV_PORT: 5656,
44
API_BASE_URL: isProduction
5-
? 'https://app.reactype.dev'
5+
? 'https://reactype-2c81e4204f81.herokuapp.com'
66
: 'http://localhost:5656',
77
// : 'http://localhost:8080',
88
API_BASE_URL2: isProduction
9-
? 'https://app.reactype.dev'
9+
? 'https://reactype-2c81e4204f81.herokuapp.com'
1010
: 'http://localhost:8080'
1111
};
1212
module.exports = config;

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Reactype</title>
7-
<link rel="stylesheet" type="text/css" href="./style.css" />
7+
<link
8+
rel="stylesheet"
9+
type="text/css"
10+
href="./app/src/public/styles/style.css"
11+
/>
812
<link
913
rel="icon"
1014
type="image/x-icon"

server/server.ts

Lines changed: 35 additions & 28 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('currently in port', process.env.PORT);
55+
console.log('in production');
56+
console.log('joined path: ', path.join(__dirname, '../build'));
57+
app.use('/', express.static(path.join(__dirname, '../build')));
58+
} else {
59+
console.log('not production');
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');
@@ -75,7 +89,12 @@ const httpServer = createServer(app);
7589
const io = new Server(httpServer, {
7690
transports: ['websocket'],
7791
cors: {
78-
origin: ['http://localhost:5656', 'http://localhost:8080', API_BASE_URL]
92+
origin: [
93+
process.env.PORT,
94+
'http://localhost:5656',
95+
'http://localhost:8080',
96+
API_BASE_URL
97+
]
7998
}
8099
});
81100

@@ -520,34 +539,22 @@ app.get(
520539
);
521540

522541
// serve index.html on the route '/'
523-
const isDocker = process.env.IS_DOCKER === 'true';
524-
console.log('this is running on docker: ', isDocker);
525-
526-
//if in production mode, statically serve everything in the build folder on the route '/dist'
527-
if (process.env.NODE_ENV == 'production') {
528-
app.use('/dist', express.static(path.join(__dirname, '/app/dist')));
529-
}
530-
531-
app.get('/', (req, res) => {
532-
const indexPath = isDocker
533-
? path.join(__dirname, '../index-prod.html')
534-
: path.join(__dirname, '../index.html');
535-
return res.status(200).sendFile(indexPath);
536-
});
542+
// const isDocker = process.env.IS_DOCKER === 'true';
543+
// console.log('this is running on docker: ', isDocker);
537544

538-
app.get('/bundle.js', (req, res) => {
539-
return res.status(200).sendFile(path.join(process.cwd(), 'bundle.js'));
540-
});
545+
// app.get('/bundle.js', (req, res) => {
546+
// return res.status(200).sendFile(path.join(process.cwd(), 'bundle.js'));
547+
// });
541548

542-
if (isDocker) {
543-
app.get('/main.css', (req, res) => {
544-
return res.status(200).sendFile(path.join(process.cwd(), 'main.css'));
545-
});
546-
}
549+
// if (isDocker) {
550+
// app.get('/main.css', (req, res) => {
551+
// return res.status(200).sendFile(path.join(process.cwd(), 'main.css'));
552+
// });
553+
// }
547554

548-
app.get('/test', (req, res) => {
549-
res.send('test request is working');
550-
});
555+
// app.get('/test', (req, res) => {
556+
// res.send('test request is working');
557+
// });
551558

552559
app.use('/*', (req, res) => res.status(404).send('Page not found'));
553560

@@ -565,8 +572,8 @@ app.use((err, req, res, next) => {
565572

566573
// starts server on PORT
567574
if (!isTest) {
568-
httpServer.listen(5656, () =>
569-
console.log(`Server listening on port: ${DEV_PORT}`)
575+
httpServer.listen(PORT, () =>
576+
console.log(`Server listening on port: ${PORT}`)
570577
);
571578
}
572579

0 commit comments

Comments
 (0)