Skip to content

Commit 504fc8d

Browse files
update cors and port
1 parent 9b7ea35 commit 504fc8d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

chat-app/backend/server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import express from "express";
22
import cors from "cors";
33

44
const app = express();
5-
const PORT = 3000;
5+
const PORT = process.env.PORT || 3000;
66

77
app.use(express.json());
8-
app.use(cors());
8+
app.use(cors({
9+
origin: "*"
10+
}));
911

1012
let messages = [];
1113

@@ -29,7 +31,7 @@ app.post("/", (req, res) => {
2931
res.status(201).json({ success: true });
3032
});
3133

32-
app.listen(PORT, () => {
33-
console.log("Server running on port 3000");
34+
app.listen(PORT, "0.0.0.0", () => {
35+
console.log(`Server running on ${PORT}`);
3436
});
3537

0 commit comments

Comments
 (0)