We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS Platform:win10
Node.js Version:18.12.0
ThinkJS Version:2.2.9 错误信息: test.html:1 Access to XMLHttpRequest at 'http://127.0.0.1:8360/socket.io/?EIO=3&transport=polling&t=OH8mmgq' from origin 'http://localhost:63342' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
sever端配置: export default { on: true, //是否开启 WebSocket type: 'socket.io', //使用的 WebSocket 库类型,默认为 socket.io allow_origin: 'http://127.0.0.1', //允许的 origin adp: undefined, // socket 存储的 adapter,socket.io 下使用 path: '', //url path for websocket messages: { open: 'home/socketio/open', }, }; 客户端:代码: import io from "socket.io-client" const socket = io('http://127.0.0.1:8360');
function sendOpen(){ //发送事件 socket.emit('open', 'data'); //监听事件 socket.on('open', function(data){ console.log("open call back") }) console.log("open") }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
DESC
ENV
OS Platform:win10
Node.js Version:18.12.0
ThinkJS Version:2.2.9
错误信息:
test.html:1 Access to XMLHttpRequest at 'http://127.0.0.1:8360/socket.io/?EIO=3&transport=polling&t=OH8mmgq' from origin 'http://localhost:63342' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
sever端配置:
export default {
on: true, //是否开启 WebSocket
type: 'socket.io', //使用的 WebSocket 库类型,默认为 socket.io
allow_origin: 'http://127.0.0.1', //允许的 origin
adp: undefined, // socket 存储的 adapter,socket.io 下使用
path: '', //url path for websocket
messages: {
open: 'home/socketio/open',
},
};
客户端:代码:
import io from "socket.io-client"
const socket = io('http://127.0.0.1:8360');
function sendOpen(){
//发送事件
socket.emit('open', 'data');
//监听事件
socket.on('open', function(data){
console.log("open call back")
})
console.log("open")
}
The text was updated successfully, but these errors were encountered: