I'm trying to get the api calls for our app from the subdomain, it's not working as desired.
$app->group('/api', function (RouteCollectorProxy $group) {
$group->get('/home', [\App\Controllers\HomeController::class, 'apihome']);
});
I've set our api.domain.com to point to domain.com/public and that just mirrors the main app. In other words, it all words fine, however, we like to get this:
- [x] api.domain.com/api/home
- [v] api.domain.com/home
I've tried a lot of suggestions, like htacess rules and middleswares. None helped.
RewriteEngine On
# Rewrite requests to the "api" subdomain to the /public/api directory
RewriteCond %{HTTP_HOST} ^api\.domain\.com$
RewriteRule ^(.*)$ /api/$1 [L]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
Tried some other code suggestions, too. No luck.
$app->add(new HostMiddleware('api.example.com'));
Can anybody lend a hand?