Commit 2ce56318 authored by Vũ Gia Vương's avatar Vũ Gia Vương

add path /socket

parent 8d0f13ca
...@@ -10,6 +10,7 @@ const socket_1 = require("./socket"); ...@@ -10,6 +10,7 @@ const socket_1 = require("./socket");
const PORT = 3001; const PORT = 3001;
const server = http_1.default.createServer(server_1.default); const server = http_1.default.createServer(server_1.default);
const io = new socket_io_1.Server(server, { const io = new socket_io_1.Server(server, {
path: '/socket',
cors: { cors: {
// origin: '*', // origin: '*',
methods: ["GET", "POST"], methods: ["GET", "POST"],
......
...@@ -11,7 +11,7 @@ app.use(express_1.default.json()); ...@@ -11,7 +11,7 @@ app.use(express_1.default.json());
app.get('/', (req, res, next) => { app.get('/', (req, res, next) => {
res.send('Hello World'); res.send('Hello World');
}); });
app.get('/socket', (req, res, next) => { // app.get('/socket', (req: Request, res: Response, next: NextFunction) => {
res.send('socket'); // res.send('socket')
}); // })
exports.default = app; exports.default = app;
...@@ -7,11 +7,12 @@ const PORT = 3001; ...@@ -7,11 +7,12 @@ const PORT = 3001;
const server = http.createServer(app); const server = http.createServer(app);
const io = new Server(server, { const io = new Server(server, {
path: '/socket',
cors: { cors: {
// origin: '*', // origin: '*',
methods: ["GET", "POST"], methods: ["GET", "POST"],
// origin: ["http://localhost:7456"], // origin: ["http://localhost:7456"],
origin: ["https://play.gamee.vn","https://dev.gamee.vn","http://localhost:7456"], origin: ["https://play.gamee.vn", "https://dev.gamee.vn", "http://localhost:7456"],
credentials: true, credentials: true,
} }
}); });
......
...@@ -8,8 +8,9 @@ app.use(express.json()); ...@@ -8,8 +8,9 @@ app.use(express.json());
app.get('/', (req: Request, res: Response, next: NextFunction) => { app.get('/', (req: Request, res: Response, next: NextFunction) => {
res.send('Hello World') res.send('Hello World')
}) })
app.get('/socket', (req: Request, res: Response, next: NextFunction) => {
res.send('socket') // app.get('/socket', (req: Request, res: Response, next: NextFunction) => {
}) // res.send('socket')
// })
export default app; export default app;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment