Skip to content

Commit

Permalink
fix: socket.io v4 连接异常问题
Browse files Browse the repository at this point in the history
fix #190
  • Loading branch information
cumt-robin committed Dec 17, 2024
1 parent fa437b9 commit 5d42650
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/thick-kangaroos-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"nest-server": patch
"cra-react18": patch
"vite-vue3": patch
"webpack-vue3": patch
---

fix: socket.io v4 连接异常问题
1 change: 1 addition & 0 deletions app/cra-react18/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NODE_ENV=production
REACT_APP_SOCKET_SERVER=""
2 changes: 1 addition & 1 deletion app/nest-server/src/modules/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Server, Socket } from "socket.io";
cors: {
origin: (origin, callback) => {
const list = process.env.WEB_SOCKET_WHITE_LIST.split(",");
if (list.includes(origin)) {
if (!origin || list.includes(origin)) {
callback(null, true);
} else {
callback(new Error("Not allowed by CORS"));
Expand Down
2 changes: 1 addition & 1 deletion app/vite-vue3/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# 生产环境变量
VITE_APP_SOCKET_SERVER=https://blog.wbjiang.cn
VITE_APP_SOCKET_SERVER=""
2 changes: 1 addition & 1 deletion app/webpack-vue3/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# 生产环境变量
VUE_APP_SOCKET_SERVER=https://blog.wbjiang.cn
VUE_APP_SOCKET_SERVER=""

0 comments on commit 5d42650

Please sign in to comment.