As designed Unable to query API without full friendly URLs enabled

Lukas W.

Well-known member
Affected version
2.2.2
When querying the API without full friendly URLs, the index.php condition \XF::requestUrlMatchesApi() fails its check due to receiving an escaped version of the route path from XF\Http\Request.

http://localhost/xf2/index.php?api/test will result into a base path of api%2Ftest, which fails the regular expression #^api(?:/|$)#i. As a result, the public app is launched, and fails to identify the correct route.
 
According to the code, XF will assume that SEO friendly URLs is enabled for API:
PHP:
        $container['router.api.formatter'] = function ($c)
        {
            // Note: always enforcing friendly URLs for the API for consistency.
            //if ($c['options']->useFriendlyUrls)
            if (true)
            {
 
Yes, this is generally intentional to ensure that the API routes are consistent across any install, both for documentation purposes and for implementation purposes. (I'll need to double check whether this is mentioned in the docs as it likely should be.)
 
Top Bottom