一般來(lái)說(shuō),設(shè)置header('Access-Control-Allow-Origin:*')即可,在worker中設(shè)置時(shí),會(huì)報(bào)Cannot modify header information - headers already sent by (output started at /Users/Deby/Sites/paakee/vendor/Workerman/Worker.php:1305),改如何處理呢?
workerman是在php cli下運(yùn)行的,php cli下不支持header() 函數(shù)。 用 \Workerman\Protocols\Http::header() 代替header()。
Uncaught Error: Call to undefined method Workerman\Protocols\Http::header()
這個(gè)是很老的帖子了。header這些基本用法請(qǐng)看手冊(cè)