From 006e32018c8f416aade83271a5dc8a33fe387c1f Mon Sep 17 00:00:00 2001 From: Roger Stringer Date: Wed, 30 Nov 2022 10:26:08 -0800 Subject: [PATCH 1/3] bearer returns a promise rather than awaiting --- gatsby-node.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 0292ced..f1e594e 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -283,9 +283,10 @@ class Plugin { Object.assign(headers, (await this.options.headers()) || {}); } - if (this.directus.auth.token) { + if (await this.directus.auth.token) { + const token = await this.directus.auth.token; Object.assign(headers, { - Authorization: `Bearer ${this.directus.auth.token}`, + Authorization: `Bearer ${token}`, }); } From 5dce13d789a6420c09a9e282cb97ac8fc5562a4a Mon Sep 17 00:00:00 2001 From: Roger Stringer Date: Wed, 30 Nov 2022 10:27:12 -0800 Subject: [PATCH 2/3] new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed129eb..67eaf96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@directus/gatsby-source-directus", - "version": "9.14.6", + "version": "9.14.7", "description": "Source plugin for pulling data into Gatsby from a Directus API.", "author": "João Biondo ", "license": "MIT", From d30fcb43408da27fb0102b78fc5e33eb3f9319bb Mon Sep 17 00:00:00 2001 From: Roger Stringer Date: Wed, 30 Nov 2022 10:35:37 -0800 Subject: [PATCH 3/3] move token outside if --- gatsby-node.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index f1e594e..eff7b6b 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -283,8 +283,9 @@ class Plugin { Object.assign(headers, (await this.options.headers()) || {}); } - if (await this.directus.auth.token) { - const token = await this.directus.auth.token; + const token = await this.directus.auth.token; + + if (token) { Object.assign(headers, { Authorization: `Bearer ${token}`, });