使用workerman 部署服務(wù)器用于請(qǐng)求返回
$text_worker = new Worker("http://0.0.0.0:88");
正常啟動(dòng) 無(wú)報(bào)錯(cuò)
然后:
$http.get('http://xxx.xxx.xxx.xxx:88', {。。。。。。}
然后結(jié)果
然而當(dāng)我單獨(dú)在瀏覽器打開wokerman的http服務(wù)連接的時(shí)候有不一樣了
所以 在單獨(dú)打開連接的時(shí)候能夠獲取正常的 json返回
但是使用 $http.get 就有問(wèn)題了 請(qǐng)高人指點(diǎn)了
果然發(fā)現(xiàn)了坑
Access to XMLHttpRequest at 'http://xxx.xxx.xxx:88/?orderNo=A615205240450569&accid=d2458c4f3c96ba2ec100b56f834c0b37' from origin 'http://xxx.xxx.xxx.xxx' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
大佬一語(yǔ)點(diǎn)醒夢(mèng)中人啊 我真是迷糊了 居然把跨域給忘記了,
不過(guò)
workman 要怎么解決跨域的設(shè)置呢?
搜了一下 \Workerman\Protocols\Http::header() 解決跨域
但是具體怎么用呢 這個(gè)東東 知道的 麻煩給下代碼