<i id='mnsLs'><tr id='mnsLs'><dt id='mnsLs'><q id='mnsLs'><span id='mnsLs'><b id='mnsLs'><form id='mnsLs'><ins id='mnsLs'></ins><ul id='mnsLs'></ul><sub id='mnsLs'></sub></form><legend id='mnsLs'></legend><bdo id='mnsLs'><pre id='mnsLs'><center id='mnsLs'></center></pre></bdo></b><th id='mnsLs'></th></span></q></dt></tr></i><div id='mnsLs'><tfoot id='mnsLs'></tfoot><dl id='mnsLs'><fieldset id='mnsLs'></fieldset></dl></div>
    1. <legend id='mnsLs'><style id='mnsLs'><dir id='mnsLs'><q id='mnsLs'></q></dir></style></legend>
    2. <small id='mnsLs'></small><noframes id='mnsLs'>

      <tfoot id='mnsLs'></tfoot>
      • <bdo id='mnsLs'></bdo><ul id='mnsLs'></ul>

        socket.io,“访问控制允许来源"错误

        时间:2023-10-14

              <tbody id='4H5Mv'></tbody>
            1. <small id='4H5Mv'></small><noframes id='4H5Mv'>

                <bdo id='4H5Mv'></bdo><ul id='4H5Mv'></ul>
                <legend id='4H5Mv'><style id='4H5Mv'><dir id='4H5Mv'><q id='4H5Mv'></q></dir></style></legend>
                <i id='4H5Mv'><tr id='4H5Mv'><dt id='4H5Mv'><q id='4H5Mv'><span id='4H5Mv'><b id='4H5Mv'><form id='4H5Mv'><ins id='4H5Mv'></ins><ul id='4H5Mv'></ul><sub id='4H5Mv'></sub></form><legend id='4H5Mv'></legend><bdo id='4H5Mv'><pre id='4H5Mv'><center id='4H5Mv'></center></pre></bdo></b><th id='4H5Mv'></th></span></q></dt></tr></i><div id='4H5Mv'><tfoot id='4H5Mv'></tfoot><dl id='4H5Mv'><fieldset id='4H5Mv'></fieldset></dl></div>
                <tfoot id='4H5Mv'></tfoot>

                • 本文介绍了socket.io,“访问控制允许来源"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  I have set up a node server with socket io turning and trying to connect to it through another server. However some browsers on different computers give me this error and makes it reconnect the whole time:

                  XMLHttpRequest cannot load https://serverDomain.net:3000/socket.io/?EIO=3&transport=polling&t=Lo_SdiU. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://www.differentServerDomain.fr' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

                  my js config:

                  var port = 3000;
                  var fs = require('fs');
                  var https = require('https');
                  var express = require('express');
                  var app = express();
                  
                  var options = {
                      key: fs.readFileSync('/etc/letsencrypt/live/devpeter.net/privkey.pem'),
                      cert: fs.readFileSync('/etc/letsencrypt/live/devpeter.net/fullchain.pem')
                  };
                  var server = https.createServer(options, app);
                  var io = require('socket.io')(server);
                  io.origins('https://www.differentServerDomain.fr:* https://www.differentServerDomain.fr/wp-admin/index.php:*');
                  
                  // start of server
                  server.listen(port, function(){
                      console.log('listening on *: '+ port + "
                  ");
                  });
                  

                  I am using node 8.0 and socket io 2.2, Your help will be greatly appreciated.

                  EDIT: here is the client code:

                  <script src="https://serverDomain.net:3000/socket.io/socket.io.js"></script>
                  <script>
                     var socket = io('https://serverDomain.net:3000');
                  </script>
                  

                  解决方案

                  I have found a solution. for some reason the default transportation method is not always allowed by all servers.

                  So i specified a neutral transportation method at the client side, like this:

                  var socket = io('https://yourDomain:3000', { transports : ['websocket'] });
                  

                  这篇关于socket.io,“访问控制允许来源"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将所有域添加到 CORS 的安全隐患(访问控制允许来 下一篇:ReactJS API 数据获取 CORS 错误

                  相关文章

                  最新文章

                  <tfoot id='kaW3k'></tfoot>

                  1. <legend id='kaW3k'><style id='kaW3k'><dir id='kaW3k'><q id='kaW3k'></q></dir></style></legend>

                    <small id='kaW3k'></small><noframes id='kaW3k'>

                  2. <i id='kaW3k'><tr id='kaW3k'><dt id='kaW3k'><q id='kaW3k'><span id='kaW3k'><b id='kaW3k'><form id='kaW3k'><ins id='kaW3k'></ins><ul id='kaW3k'></ul><sub id='kaW3k'></sub></form><legend id='kaW3k'></legend><bdo id='kaW3k'><pre id='kaW3k'><center id='kaW3k'></center></pre></bdo></b><th id='kaW3k'></th></span></q></dt></tr></i><div id='kaW3k'><tfoot id='kaW3k'></tfoot><dl id='kaW3k'><fieldset id='kaW3k'></fieldset></dl></div>
                      <bdo id='kaW3k'></bdo><ul id='kaW3k'></ul>