Updated socket connection code to support docker.

This commit is contained in:
Karmaa
2025-02-09 21:35:45 -06:00
parent 175225dcd7
commit a6b03aa792
2 changed files with 7 additions and 6 deletions

View File

@@ -29,9 +29,9 @@ http {
proxy_cache_bypass $http_upgrade;
# CORS headers
add_header 'Access-Control-Allow-Origin' '*'; # Allow all origins (can be restricted to a specific domain)
add_header 'Access-Control-Allow-Methods' 'GET, POST'; # Allow GET and POST methods
add_header 'Access-Control-Allow-Headers' 'Content-Type, Accept'; # Standard headers for requests
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Accept';
}
# Error pages

View File

@@ -7,8 +7,9 @@ const io = socketIo(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
transports: ["polling", "websocket"],
},
allowedHeaders: ["Content-Type", "Accept"],
credentials: false
}
});
io.on("connection", (socket) => {
@@ -96,6 +97,6 @@ io.on("connection", (socket) => {
});
});
server.listen(8081, () => {
server.listen(8081, '0.0.0.0', () => {
console.log("Server is running on port 8081");
});