Hello
I am using a multidomain setup, and ideally trying to grab site content from every main domain and display it on a certain template.
Template controller
<?php
return function ($site) {
$req = Remote::get('https://other-main-domain-url/api/kirby-users');
return [
'controllerData' => $req,
];
};
Custom plugin folder and its index.php file:
<?php
Kirby::plugin('my/api', [
'api' => [
'routes' => function ($kirby) {
return [
[
'pattern' => 'kirby-users',
'action' => function () use ($kirby) {
return [
'users' => $kirby->users()->count()
];
}
]
];
}
]
]);
Php template file:
<?php
dump($controllerData);
?>
It returns:
Server Error 401 - Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn’t understand how to supply the credentials required.
I tried enabling the allowInsecure property, also tried doing it via config file directly. Couldn’t find in the docs where exactly I am missing an authorisation part where this api call can be allowed, maybe you can help?
Thanks!