Skip to content

Commit 687ca20

Browse files
feat(config): Allow options to be passed to algoliasearch (#158)
* feat(config): Add requester param to pass it to algoliasearch to use a corporate proxy We're using a corporate proxy and cannot make `gatsby-plugin-algolia` work without passing a custom requester. I found this PR (algolia/algoliasearch-client-javascript#1180) where `createNodeHttpRequester` was extended to pass a custom HTTP agent. With this change you can pass a custom requester to `gatsby-plugin-algolia` which resolved our issue. * feat(config): Add param to set the algoliasearch options * docs(readme): include algoliasearchOptions Co-authored-by: Haroen Viaene <[email protected]>
1 parent e7c80b1 commit 687ca20

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ module.exports = {
9595
concurrentQueries: false, // default: true
9696
skipIndexing: true, // default: false, useful for e.g. preview deploys or local development
9797
continueOnFailure: false, // default: false, don't fail the build if algolia indexing fails
98+
algoliasearchOptions: undefined, // default: { timeouts: { connect: 1, read: 30, write: 30 } }, pass any different options to the algoliasearch constructor
9899
},
99100
},
100101
],

gatsby-node.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ exports.onPostBuild = async function ({ graphql, reporter }, config) {
4141
skipIndexing = false,
4242
dryRun = false,
4343
continueOnFailure = false,
44+
algoliasearchOptions = {
45+
timeouts: {
46+
connect: 1,
47+
read: 30,
48+
write: 30,
49+
},
50+
},
4451
} = config;
4552

4653
const activity = reporter.activityTimer(`index to Algolia`);
@@ -69,13 +76,7 @@ exports.onPostBuild = async function ({ graphql, reporter }, config) {
6976
return;
7077
}
7178

72-
const client = algoliasearch(appId, apiKey, {
73-
timeouts: {
74-
connect: 1,
75-
read: 30,
76-
write: 30,
77-
},
78-
});
79+
const client = algoliasearch(appId, apiKey, algoliasearchOptions);
7980

8081
activity.setStatus(`${queries.length} queries to index`);
8182

0 commit comments

Comments
 (0)