Website: Update Fleet website search index when website server starts. (#9480)

Changes:
- Updated the custom hook to include a POST request to Algolia to
refresh the Fleetdm.com search index.

Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
This commit is contained in:
Eric 2023-01-25 10:09:41 -06:00 committed by GitHub
parent efc34ebe70
commit 5fabe6ce2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,6 +84,16 @@ will be disabled and/or hidden in the UI.
fromName: sails.config.custom.fromName,
});
if(sails.config.environment === 'production'){
sails.helpers.http.post.with({
url: `https://crawler.algolia.com/api/1/crawlers/${sails.config.custom.algoliaCrawlerId}/reindex`,
headers: { 'Authorization': sails.config.custom.algoliaCrawlerApiToken}
}).exec((err)=>{
if(err){
sails.log.warn('When trying to send a request to Algolia to refresh the Fleet website search index, an error occurred: '+err);
}
});//_∏_
}
});//_∏_
// ... Any other app-specific setup code that needs to run on lift,