Skip to content

Commit 08efdaa

Browse files
committed
feat: add CORS support in server
1 parent 00c32c8 commit 08efdaa

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

chat-app/backend/server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const express = require('express');
22
const path = require('path');
3+
const cors = require('cors');
34

45
const app = express();
56
const PORT = process.env.PORT || 3000;
67

8+
app.use(cors());
79
app.use(express.json());
810
app.use(express.static(path.join(__dirname, '../frontend')));
911

chat-app/frontend/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM nginx:1.27-alpine
2+
3+
COPY index.html /usr/share/nginx/html/index.html
4+
COPY style.css /usr/share/nginx/html/style.css
5+
COPY app.js /usr/share/nginx/html/app.js
6+
7+
EXPOSE 80
8+
9+
CMD ["nginx", "-g", "daemon off;"]

chat-app/frontend/package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
"main": "app.js",
66
"keywords": ["chat", "frontend"],
77
"author": "",
8+
"license": "UNLICENSED",
9+
"private": true,
810
"dependencies": {}
9-
10-
"scripts": {
11-
"start": "node server.js",
12-
"dev": "node --watch server.js"
13-
},
14-
"dependencies": {
15-
"cors": "^2.8.5",
16-
"express": "^4.21.2"
17-
}
1811
}

0 commit comments

Comments
 (0)