Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-server-flip-jump
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Gia Vương
game-server-flip-jump
Commits
2030735c
Commit
2030735c
authored
Aug 19, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix cors true true
parent
2ce56318
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
index.js
dist/index.js
+13
-3
index.ts
src/index.ts
+13
-3
No files found.
dist/index.js
View file @
2030735c
...
...
@@ -12,10 +12,20 @@ const server = http_1.default.createServer(server_1.default);
const
io
=
new
socket_io_1
.
Server
(
server
,
{
path
:
'/socket'
,
cors
:
{
// origin: '*',
methods
:
[
"GET"
,
"POST"
],
// origin: ["http://localhost:7456"],
origin
:
[
"https://play.gamee.vn"
,
"https://dev.gamee.vn"
,
"http://localhost:7456"
],
origin
:
(
origin
,
callback
)
=>
{
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
,
}
});
...
...
src/index.ts
View file @
2030735c
...
...
@@ -9,12 +9,22 @@ const server = http.createServer(app);
const
io
=
new
Server
(
server
,
{
path
:
'/socket'
,
cors
:
{
// origin: '*',
methods
:
[
"GET"
,
"POST"
],
// origin: ["http://localhost:7456"],
origin
:
[
"https://play.gamee.vn"
,
"https://dev.gamee.vn"
,
"http://localhost:7456"
],
origin
:
(
origin
,
callback
)
=>
{
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
,
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment