fix: get ip in cli mode

This commit is contained in:
tlanyan 2021-01-12 21:08:21 +08:00
parent 8b5aa07b1f
commit 33ccd5898a

View File

@ -29,7 +29,12 @@ $loop->run();
function handler(Psr\Http\Message\ServerRequestInterface $req) {
$ip = $req->getHeader('REMOTE_ADDR')[0];
$ip = $req->getHeader('REMOTE_ADDR');
if (!$ip) {
$ip = $req->getServerParams()['REMOTE_ADDR'];
} else {
$ip = $ip[0];
}
$url = $req->getUri()->getPath();
// strip start /
$url = substr($url, 1);