From fbcd50444c5c552a49175bbcbb1f363d67c6dde8 Mon Sep 17 00:00:00 2001 From: Matteljay Date: Mon, 2 Aug 2021 16:03:39 +0200 Subject: [PATCH] Auth patch to @directus/gatsby-source-directus (#7119) Gatsby needs one-time access to the images at build time with the secure access token. With this security patch it is now no longer needed to have all Directus files continuously exposed to the public. Co-authored-by: Rijk van Zanten --- packages/gatsby-source-directus/gatsby-node.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-source-directus/gatsby-node.js b/packages/gatsby-source-directus/gatsby-node.js index b7a6637ba7..e8f82ff8fc 100644 --- a/packages/gatsby-source-directus/gatsby-node.js +++ b/packages/gatsby-source-directus/gatsby-node.js @@ -169,7 +169,7 @@ exports.sourceNodes = async (gatsby, options) => { exports.createResolvers = async ({ actions, cache, createNodeId, createResolvers, store, reporter }, options) => { const { createNode } = actions; - const { url } = options; + const { url, auth } = options; let endpoints = normalizeEndpoint(url); @@ -187,6 +187,7 @@ exports.createResolvers = async ({ actions, cache, createNodeId, createResolvers cache, createNode, createNodeId, + httpHeaders: { Authorization: `Bearer ${auth.token}` }, reporter, }); },