diff --git a/backend/server.js b/backend/server.js index 18c1e84..d77090f 100644 --- a/backend/server.js +++ b/backend/server.js @@ -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); @@ -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); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index a213a34..4ed74c4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -15,6 +15,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", @@ -27,6 +28,25 @@ "web-vitals": "^2.1.4" } }, + "..": { + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "bcryptjs": "^2.4.3", + "colors": "^1.4.0", + "cookie-parser": "^1.4.6", + "express": "^4.18.3", + "jsonwebtoken": "^9.0.2", + "mongoose": "^8.2.1", + "multer": "^1.4.5-lts.1", + "react-helmet-async": "^2.0.4" + }, + "devDependencies": { + "concurrently": "^8.2.2", + "dotenv": "^16.4.5", + "nodemon": "^3.1.0" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -14978,6 +14998,10 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/proshop": { + "resolved": "..", + "link": true + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", diff --git a/frontend/package.json b/frontend/package.json index 08afccf..a062b32 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", diff --git a/package.json b/package.json index c38ea61..bdb3269 100644 --- a/package.json +++ b/package.json @@ -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",