国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

web-msg-sender一直提示已攔截跨源請求:同源策略禁止讀取位于...的遠程資源,請問大神該如何解決?

何雨

按照github上提示做的,網(wǎng)址:https://github.com/walkor/phpsocket.io/tree/master/docs/zh
截圖如下

圖片

但是打開火狐一直提示“已攔截跨源請求:同源策略禁止讀取位于 http://39.106.121.125:3120/socket.io/?EIO=3&transport=polling&t=MUbA4T7 的遠程資源”
截圖如下

圖片
?
?
客戶端訪問鏈接是:http://39.106.121.125/PHPCode/tools/web_socket/index.html
這個鏈接的源碼是

<html>
<head>
<script src='https://cdn.bootcss.com/socket.io/2.0.3/socket.io.js'></script>
<script>
// 如果服務端不在本機,請把127.0.0.1改成服務端ip
console.log('成立');
var socket = io('http://39.106.121.125:3120');
// 當連接服務端成功時觸發(fā)connect默認事件
socket.on('connect', function(){
    console.log('connect success');
});
</script>

</head>
<body>

</body>
</html>

服務端php源碼

<?php
require_once '../web-msg-sender/vendor/autoload.php';
use Workerman\Worker;
use PHPSocketIO\SocketIO;

$io = new SocketIO(3120);
// 當有客戶端連接時
$io->on('connection', function($socket)use($io){
  // 定義chat message事件回調(diào)函數(shù)
  $socket->on('chat message', function($msg)use($io){
    // 觸發(fā)所有客戶端定義的chat message from server事件
    $io->emit('chat message from server', $msg);
  });
});
Worker::runAll();

服務器啟動該php程序提示如下
圖片
?
請問大神該如何解決這個跨域問題?

7903 1 0
1個回答

何雨

額,好吧,我忘記開放3120端口了,

  • 暫無評論
年代過于久遠,無法發(fā)表回答
??