Skip to content

Commit

Permalink
Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mmli1 committed Jan 12, 2025
1 parent 7d2ee3a commit d3497a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "path";
import express from "express";
import dotenv from "dotenv";
import cookieParser from "cookie-parser";
Expand All @@ -11,6 +12,8 @@ import { app, server } from "./socket/socket.js";
//const app = express(); moved to socket.js as a lower layer
const PORT = process.env.PORT || 5000;

const __dirname = path.resolve();

dotenv.config();

app.use(express.json()); // to parse the incoming requests with JSON payloads (from req.body)
Expand All @@ -22,10 +25,11 @@ app.use("/api/auth", authRoutes);
app.use("/api/messages", messageRoutes);
app.use("/api/users", userRoutes);

// app.get("/", (req, res) => {
// // root route http://localhost:5000/
// res.send("Hello World!!");
// });
app.use(express.static(path.join(__dirname, "/frontend/dist")));

app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "frontend", "dist", "index.html"))
});

server.listen(PORT, () => {
connectToMongoDB();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/messages/MessageContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MessageContainer = () => {
};

const NoChatSelected = () => {
const {authUser} = useAuthContext();
const { authUser } = useAuthContext();
return (
<div className="flex items-center justify-center w-full h-full">
<div className="px-4 text-center sm:text-lg md:text-xl text-gray-200 font-semibold flex flex-col items-center gap-2">
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "1.0.0",
"main": "server.js",
"scripts": {
"server": "nodemon backend/server.js"
"server": "nodemon backend/server.js",
"start": "node backend/server.js",
"build": "npm install && npm install --prefix frontend && npm run build --prefix frontend"
},
"type": "module",
"keywords": [],
Expand Down

0 comments on commit d3497a8

Please sign in to comment.