XMLHttpRequest cannot load “”“”. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access.
我在瀏覽器上面調(diào)試會出現(xiàn)這個問題 之前用ngix時候用header的設(shè)置一下 Access-Control-Allow-Origin 就可以了
現(xiàn)在php cli不支持header 現(xiàn)在workerman是用\Workerman\Protocols\Http::header 這個來代替
我想問一下 我用Gatewayworker我要怎么設(shè)置 設(shè)置在哪里
是在我的start_web里面來設(shè)置header 還是在我的 $web->addRoot('www.your_domain.com', __DIR__.'/Test');
這個root下面的比如index.php里面來設(shè)置
GatewayWorker 是用來做tcp長鏈接的,不適合做http應(yīng)用。
GatewayWorker中也無法使用\Workerman\Protocols\Http::header
http協(xié)議的應(yīng)用直接使用 new Worker('http://..');
或者 new WebServer('http://...');
最好是用nginx php-fpm,使用起來最簡單。
我用的就是webserver $web = new WebServer("http://192.168.6.114:55151"); 這種情況 我能設(shè)置跨域么 我這邊要求的服務(wù)有webserver也有tcp的 所以我就啟動了兩種 這種情況下 我要怎么設(shè)置呢?