Commit 2030735c authored by Vũ Gia Vương's avatar Vũ Gia Vương

fix cors true true

parent 2ce56318
...@@ -12,10 +12,20 @@ const server = http_1.default.createServer(server_1.default); ...@@ -12,10 +12,20 @@ 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', path: '/socket',
cors: { cors: {
// origin: '*',
methods: ["GET", "POST"], methods: ["GET", "POST"],
// origin: ["http://localhost:7456"], origin: (origin, callback) => {
origin: ["https://play.gamee.vn", "https://dev.gamee.vn", "http://localhost:7456"], const allowed = [
"https://play.gamee.vn",
"https://dev.gamee.vn",
"http://localhost:7456"
];
if (!origin || allowed.includes(origin)) {
callback(null, origin);
}
else {
callback(new Error("Not allowed by CORS"));
}
},
credentials: true, credentials: true,
} }
}); });
......
...@@ -9,12 +9,22 @@ const server = http.createServer(app); ...@@ -9,12 +9,22 @@ const server = http.createServer(app);
const io = new Server(server, { const io = new Server(server, {
path: '/socket', path: '/socket',
cors: { cors: {
// origin: '*',
methods: ["GET", "POST"], methods: ["GET", "POST"],
// origin: ["http://localhost:7456"], origin: (origin, callback) => {
origin: ["https://play.gamee.vn", "https://dev.gamee.vn", "http://localhost:7456"], const allowed = [
"https://play.gamee.vn",
"https://dev.gamee.vn",
"http://localhost:7456"
];
if (!origin || allowed.includes(origin)) {
callback(null, origin);
} else {
callback(new Error("Not allowed by CORS"));
}
},
credentials: true, credentials: true,
} }
}); });
......
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