Set the Master API Key
Closed this issue · 2 comments
How do you configure the master key? I didn't see it in the docs. I tried this:
config :meilisearch,
api_key: System.get_env("MEILI_MASTER_KEY")
I'm pretty sure I'm getting that value at runtime but getting this back when I do the search: {:error, nil, :econnrefused}
The documentation for the new configuration approach is in the readme, https://github.com/robottokauf3/meilisearch-elixir#application-config. I went down a rabbit hole while updating the documentation for #5 and will add better configuration instructions when I push the updates.
You can use the MEILISEARCH_API_KEY
env var to set the API key. The library will use the env var (at runtime) if available, then app configuration, and finally it will use the built-in defaults if neither of those are provided. https://github.com/robottokauf3/meilisearch-elixir/blob/master/lib/meilisearch/config.ex
One thing to note, System.get_env
in the app config is run at compile time when building a release.
I found my issue. I needed to set the endpoint differently depending upon the environment. So:
dev.exs
:
config :meilisearch,
endpoint: "http://127.0.0.1:7700",
api_key: System.get_env("MEILI_MASTER_KEY")
config.exs
:
config :meilisearch,
endpoint: "https://meili.mysite.com",
api_key: System.get_env("MEILI_MASTER_KEY")