Skip to content

Commit

Permalink
PORT variable assigned after calling the dotenv.config()
Browse files Browse the repository at this point in the history
  • Loading branch information
burakorkmez committed Apr 26, 2024
1 parent 5e2c5ec commit fea5711
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MERN Stack Project: Build and Deploy a Real Time Chat App | JWT, Socket.io

![Demo App](https://i.ibb.co/gFSMzKN/1.png)
![Demo App](https://i.ibb.co/fXmZdnz/Screenshot-10.png)

[Video Tutorial on Youtube](https://youtu.be/HwCqsOis894)

Expand Down
6 changes: 3 additions & 3 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import userRoutes from "./routes/user.routes.js";
import connectToMongoDB from "./db/connectToMongoDB.js";
import { app, server } from "./socket/socket.js";

const PORT = process.env.PORT || 5000;
dotenv.config();

const __dirname = path.resolve();

dotenv.config();
// PORT should be assigned after calling dotenv.config() because we need to access the env variables. Didn't realize while recording the video. Sorry for the confusion.
const PORT = process.env.PORT || 5000;

app.use(express.json()); // to parse the incoming requests with JSON payloads (from req.body)
app.use(cookieParser());
Expand Down

0 comments on commit fea5711

Please sign in to comment.