meilisearch: Trim whitespace from token
When reading the Meilisearch token from the file specified in the configuration, we need to ensure any whitespace are trimmed from the string. If the token file was created with a text editor, or even a shell pipeline, it's likely to have a trailing newline character. If we do not remove this, authenticated requests to Meilisearch will fail.
This commit is contained in:
@@ -20,7 +20,7 @@ impl TryFrom<&Config> for Client {
|
||||
Some(t) => Some(std::fs::read_to_string(t).map_err(Error::Token)?),
|
||||
None => None,
|
||||
};
|
||||
Ok(Client::new(&config.meilisearch.url, token)?)
|
||||
Ok(Client::new(&config.meilisearch.url, token.as_deref().map(str::trim))?)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user