From 5fabe6ce2d1266873698a68fa7eec8e318f23446 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 25 Jan 2023 10:09:41 -0600 Subject: [PATCH] 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 --- website/api/hooks/custom/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/api/hooks/custom/index.js b/website/api/hooks/custom/index.js index f3b0cc20d5..9fb3a2a9c4 100644 --- a/website/api/hooks/custom/index.js +++ b/website/api/hooks/custom/index.js @@ -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,