跨服务器 websocket
当我尝试连接到我的 websocket 服务器时,出现此错误:
Error during WebSocket handshake: origin mismatch: http://skerit.com != http://kipdola.be
果然,我必须输入源响应,如下所示:
self.client.send("Sec-WebSocket-Origin: http://kipdola.be\r\n")
self.client.send("Sec-WebSocket-Location: ws://kipdola.be:1234/\r\n")
但是如何将其设置为允许多个源?
I get this error when I try to connect to my websocket server:
Error during WebSocket handshake: origin mismatch: http://skerit.com != http://kipdola.be
Sure enough, I had to put in an origin response, like this:
self.client.send("Sec-WebSocket-Origin: http://kipdola.be\r\n")
self.client.send("Sec-WebSocket-Location: ws://kipdola.be:1234/\r\n")
But how do I set it to allow multiple origins?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需回显用户在请求中提供的来源,请求看起来有点像这样:
您执行服务器端检查
Origin
标头是否在允许的来源列表中,然后将来源回显回客户:You just echo back the origin the user provided in the request, the request looks somewhat like this:
You perform a serverside check if the
Origin
header is in your list of allowed origins and just echo the origin back to the client: