Skip to content

Commit

Permalink
feat(next-drupal): add UNSTABLE_DRUPAL_ACCESS_TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Feb 24, 2022
1 parent eb7900a commit 325e368
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/next-drupal/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ export async function buildHeaders({
accessToken?: AccessToken
headers?: RequestInit["headers"]
} = {}): Promise<RequestInit["headers"]> {
// This allows an access_token (preferrably long-lived) to be set directly on the env.
// This reduces the number of OAuth call to the Drupal server.
// Intentionally marked as unstable for now.
if (process.env.UNSTABLE_DRUPAL_ACCESS_TOKEN) {
headers[
"Authorization"
] = `Bearer ${process.env.UNSTABLE_DRUPAL_ACCESS_TOKEN}`

return headers
}

const token = accessToken || (await getAccessToken())
if (token) {
headers["Authorization"] = `Bearer ${token.access_token}`
Expand Down

0 comments on commit 325e368

Please sign in to comment.