CodeIgniter4 Version: v4.3.1
$this->request->getUri()->getPath() returns the route (URI path relative to baseURL).
app.baseURL = 'http://localhost:8888/ci431/public/'
When navigating to http://localhost:8888/ci431/public/test?a=b,
$uri = $this->request->getUri();
echo (string) $uri; // "http://localhost:8888/ci431/public/test?a=b" → Okay
echo $uri->getPath(); // "test" → NG. It should be "/ci431/public/test" when following PSR-7
Ref https://www.php-fig.org/psr/psr-7/
Related #5930