Skip to content

Commit

Permalink
prepares for deplayment
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurt696 committed Mar 23, 2024
1 parent 3233e92 commit 36d5df7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
14 changes: 11 additions & 3 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ app.use(express.urlencoded({ extended: true }));

app.use(cookieParser());

app.get('/', (req, res) => {
res.send('API is running...');
});


app.use('/api/products', productRoutes);
app.use('/api/users', userRoutes);
Expand All @@ -36,6 +34,16 @@ app.get('/api/config/paypal', (req, res) => res.send({ clientId: process.env.PAY
const __dirname = path.resolve();
app.use('/uploads', express.static(path.join(__dirname, '/uploads')));

if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, '/frontend/build')));

app.get('*', (req, res) => res.sendFile(path.resolve(__dirname, 'frontend', 'build', 'index.html')));
} else {
app.get('/', (req, res) => {
res.send('API is running...');
});
}

app.use(notFound);
app.use(errorHandler);

Expand Down
24 changes: 24 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/user-event": "^13.5.0",
"axios": "^1.6.7",
"bootstrap": "^5.3.3",
"proshop": "file:..",
"react": "^18.2.0",
"react-bootstrap": "^2.10.1",
"react-dom": "^18.2.0",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"client": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"data:import": "node backend/seeder.js",
"data:destroy": "node backend/seeder.js -d"
"data:destroy": "node backend/seeder.js -d",
"build": "npm install && npm install --prefix frontend && npm run build --prefix frontend"
},
"author": "Curtis Crouse",
"license": "ISC",
Expand Down

0 comments on commit 36d5df7

Please sign in to comment.