Skip to content

Commit

Permalink
express server to server static
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Aug 2, 2024
1 parent a4e6be1 commit cae3d22
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 16 deletions.
61 changes: 45 additions & 16 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"clone": "^2.1.2",
"dayjs": "^1.11.9",
"dayjs-ext": "^2.2.0",
"express": "^4.19.2",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-router-dom": "^6.9.0",
"react-scripts": "^5.0.1",
"react-use": "^17.4.0",
Expand All @@ -33,6 +35,7 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"express": "node server.js",
"start": "craco start",
"build": "craco build",
"test": "craco test",
Expand Down
15 changes: 15 additions & 0 deletions frontend/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require('express');
const bodyParser = require('body-parser')
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, 'build')));

app.get('/ping', function (req, res) {
return res.send('pong');
});

app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(process.env.PORT || 8080)

0 comments on commit cae3d22

Please sign in to comment.