studioespresso / craft-scout

Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indexes in sync with your entries.
MIT License
81 stars 54 forks source link

.env variables stopped working, unable to save plugin settings #244

Closed Joobs closed 2 years ago

Joobs commented 2 years ago

I'm not sure why but Scout stopped pulling in the .env variables. I thought it might be a caching issue so I went to the plugin settings page and went to save and it tells me "unable to save plugin settings"

It was working before, and i've not changed anything regarding Scout.

Not sure how I can diagnose the issue?

Craft: 3.7.44 Scout: 2.7.2

Joobs commented 2 years ago

I was trying to flush/update the index via the command line.

The .env variable for the Admin API key isn't working with this method, I had to hard code it. However, the Application ID works as a .env variable. So I'm not sure why variable works and the other doesn't.

I ended up flushing and rebuilding the indexes through the Utilities section.

janhenckens commented 2 years ago

Hey @Joobs That's strange, as the Utility will just use the same config and thus the same variables as the command line interface.

Are your logs showing anything when you try to save the settings?

jamesmacwhite commented 2 years ago

The settings for the key fields are all environment variable aware, I use environment variables for all three in my Scout config.

'application_id' => '$ALGOLIA_APPLICATION_ID',
'admin_api_key' => '$ALGOLIA_ADMIN_API_KEY',
'search_api_key' => '$ALGOLIA_SEARCH_API_KEY'

Which works OK, there is no reason why the admin key shouldn't work as an env var, as it's being put through parseEnv. You're not missing the $ sign before the environment name or happen to have typo with the environment name at all?

janhenckens commented 2 years ago

Closing this for now, feel free to re-open if the issue is still happening and is scout related.