Skip to content

Commit 744c07d

Browse files
mikekonowardpeet
andcommitted
fix(gatsby-source-contentful): Allow proxy to be passed in to… (#17574)
Co-authored-by: Mike Konopelski <[email protected]> Co-authored-by: Ward Peeters <[email protected]>
1 parent a9a31a6 commit 744c07d

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

packages/gatsby-source-contentful/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ List of locales and their codes can be found in Contentful app -> Settings -> Lo
156156

157157
Prevents the use of sync tokens when accessing the Contentful API.
158158

159+
**`proxy`** [object][optional] [default: `undefined`]
160+
161+
Axios proxy configuration. See the [axios request config documentation](https://github.com/mzabriskie/axios#request-config) for further information about the supported values.
162+
159163
## Notes on Contentful Content Models
160164

161165
There are currently some things to keep in mind when building your content models at Contentful.

packages/gatsby-source-contentful/src/__tests__/fetch.js

+6
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ const {
5151
createPluginConfig,
5252
} = require(`../plugin-options`)
5353

54+
const proxyOption = {
55+
host: `localhost`,
56+
port: 9001,
57+
}
5458
const options = {
5559
spaceId: `rocybtov1ozk`,
5660
accessToken: `6f35edf0db39085e9b9c19bd92943e4519c77e72c852d961968665f1324bfc94`,
5761
host: `host`,
5862
environment: `env`,
63+
proxy: proxyOption,
5964
}
6065

6166
const pluginConfig = createPluginConfig(options)
@@ -95,6 +100,7 @@ it(`calls contentful.createClient with expected params`, async () => {
95100
environment: `env`,
96101
host: `host`,
97102
space: `rocybtov1ozk`,
103+
proxy: proxyOption,
98104
})
99105
)
100106
})

packages/gatsby-source-contentful/src/fetch.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = async ({ syncToken, reporter, pluginConfig }) => {
1515
accessToken: pluginConfig.get(`accessToken`),
1616
host: pluginConfig.get(`host`),
1717
environment: pluginConfig.get(`environment`),
18+
proxy: pluginConfig.get(`proxy`),
1819
}
1920

2021
const client = contentful.createClient(contentfulClientOptions)

packages/gatsby-source-contentful/src/plugin-options.js

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const optionsSchema = Joi.object().keys({
3232
downloadLocal: Joi.boolean(),
3333
localeFilter: Joi.func(),
3434
forceFullSync: Joi.boolean(),
35+
proxy: Joi.object().keys({
36+
host: Joi.string().required(),
37+
port: Joi.number().required(),
38+
auth: Joi.object().keys({
39+
username: Joi.string(),
40+
password: Joi.string(),
41+
}),
42+
}),
3543
// default plugins passed by gatsby
3644
plugins: Joi.array(),
3745
})

0 commit comments

Comments
 (0)