Skip to content

Commit

Permalink
fix(gatsby-source-drupal): use basic auth credentials to fetch remote…
Browse files Browse the repository at this point in the history
… files as well. (gatsbyjs#10302)

* gatsby-source-drupal: use basic auth credentials also when fetching remote files.

* gatsby-source-drupal: better support the case where no basic auth is specified.
  • Loading branch information
Mario Vercellotti authored and gpetrioli committed Jan 22, 2019
1 parent 43e6671 commit d7f4ed6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/gatsby-source-drupal/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,21 @@ exports.sourceNodes = async (
}
// Resolve w/ baseUrl if node.uri isn't absolute.
const url = new URL(fileUrl, baseUrl)
// If we have basicAuth credentials, add them to the request.
const auth =
typeof basicAuth === `object`
? {
htaccess_user: basicAuth.username,
htaccess_pass: basicAuth.password,
}
: {}
fileNode = await createRemoteFileNode({
url: url.href,
store,
cache,
createNode,
createNodeId,
auth,
})
} catch (e) {
// Ignore
Expand Down

0 comments on commit d7f4ed6

Please sign in to comment.