From d7f4ed67fa007e79e0802817b28d37a8cc4512c6 Mon Sep 17 00:00:00 2001 From: Mario Vercellotti Date: Thu, 6 Dec 2018 17:23:52 +0200 Subject: [PATCH] fix(gatsby-source-drupal): use basic auth credentials to fetch remote files as well. (#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. --- packages/gatsby-source-drupal/src/gatsby-node.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/gatsby-source-drupal/src/gatsby-node.js b/packages/gatsby-source-drupal/src/gatsby-node.js index 7ca564a6b3659..5901e7cb96622 100644 --- a/packages/gatsby-source-drupal/src/gatsby-node.js +++ b/packages/gatsby-source-drupal/src/gatsby-node.js @@ -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