This was cured by composer update to bump meilisearch/meilisearch-php from 0.20.0 -> 0.21.0
Meilisearch & Scout: "Authorization header is missing"
I have provisioned 2 servers on Forge, one an App server and the other a Meilisearch server.
When running the following scout index command on the App server: php artisan scout:import "App\Models\User"
I get an error stating the following:
MeiliSearch\Exceptions\ApiException
The Authorization header is missing. It must use the bearer authorization method.
After reading the Meilisearch documentation, I can see that "requested resources are protected with an API key, that was not provided in the request header."
Okay, so just to confirm my steps to get to this point:
- Provision App server in Forge
- Provision Meilisearch server in Forge
- Put a tick in the Networking > "Can Connect To" on both servers
- Added my private Meilisearch IP as the
MEILISEARCH_HOST=http://123.456.789:7700in my app's .env file - I have also tried three different
MEILISEARCH_KEYs: the master key and both API keys that are shown in Forge's Meilisearch control panel under Meilisearch > API Keys, clearing config cache after every attempt. - Then running
php artisan scout:import "App\Models\User"after each attempt.
All versions of the MEILISEARCH_KEY result in the same error.
Using Tinker
I then have tried to manually connect to the Meilisearch server using php artisan tinker on the app server:
$client = new MeiliSearch\Client('http://123.456.789:7700', 'TRIED_MANUALLY_ADDING_API_KEYS_AND_MASTER_KEYS_ON_SEPERATE_ATTEMPTS');
The $clients always get created but when I run $client->index('foo')->search('bar') on the client, I get the same MeiliSearch\Exceptions\ApiException with message 'The Authorization header is missing. It must use the bearer authorization method.'
Can anyone shed any light on why this is happening? I have dug into some source code and read the Meilisearch docs but I don't understand what part I have missed.
Please or to participate in this conversation.