Skip to content

Commit ab9e4da

Browse files
committed
Improve checks on authentication so have wiggle room in future
1 parent 55d5516 commit ab9e4da

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/gatsby-source-filesystem/src/create-remote-file-node.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ module.exports = ({ url, store, cache, createNode, auth = {} }) =>
2626
// See if there's response headers for this url
2727
// from a previous request.
2828
const cachedHeaders = await cache.get(cacheId(url))
29-
const headers = {
30-
auth: auth.htaccess_user + `:` + auth.htaccess_pass,
29+
const headers = {}
30+
31+
// Add htaccess authentication if passed in. This isn't particularly
32+
// extensible. We should define a proper API that we validate.
33+
if (auth && auth.htaccess_pass && auth.htaccess_user) {
34+
headers.auth = `${auth.htaccess_user}:${auth.htaccess_pass}`
3135
}
36+
3237
if (cachedHeaders && cachedHeaders.etag) {
3338
headers[`If-None-Match`] = cachedHeaders.etag
3439
}

0 commit comments

Comments
 (0)