Hi everyone, hi @sebi,
First, thanks for this module I'm discovering at this moment 🙂
I got stuck a bit with something, so I wanted to share, in case.
I installed my processwire in a subfolder, as I usually do. But with your module, i got 404 with all my fetches.
So i tried to modify some stuff with the .htaccess, but never managed (point 8.A).
Finally, I found out that in your "router.php", you have a "getCurrentUrl()" function that is using "$_SERVER['REQUEST_URI']".
Unfortunately, when using a pw in a subfolder, this "$_SERVER['REQUEST_URI']" contains the full path. So the module would never find any route.
// line 177 in "Router.php"
$routeInfo = $dispatcher->dispatch($httpMethod, SELF::getCurrentUrl());
// with pw installed in a subfolder, this $routeInfo return an empty array
Only way I found out is to modify this $ with a hook:
$wire->addHookBefore('AppApi::handleApiRequest', function (HookEvent $event) {
$scriptName = $_SERVER['SCRIPT_NAME'];
$scriptDir = rtrim(dirname($scriptName), '/');
// print_r( $scriptDir."*");
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, $scriptDir) === 0) {
$_SERVER['REQUEST_URI'] = substr($uri, strlen($scriptDir));
}
});
Maybe there is another $ you could use there ?
Or maybe I missed something.
Anyway, like this, my fetches finally work, and I can really start to play with all of it 🙂
Thanks again ++