Skip to content

Commit

Permalink
Added request header support
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Sep 12, 2024
1 parent 2cbd7ee commit 90638c6
Show file tree
Hide file tree
Showing 3 changed files with 754 additions and 1,309 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"dependencies": {
"@heroicons/react": "^2.1.5",
"@mui/base": "5.0.0-beta.40",
"@next/third-parties": "^14.2.9",
"@next/third-parties": "^14.2.11",
"@tailwindcss/container-queries": "^0.1.1",
"@types/node": "^22.5.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"algoliasearch": "^5.3.2",
"algoliasearch": "^5.4.1",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
"decanter": "^7.3.0",
Expand All @@ -30,22 +30,22 @@
"graphql-request": "^7.1.0",
"graphql-tag": "^2.12.6",
"html-entities": "^2.5.2",
"html-react-parser": "^5.1.15",
"next": "^14.2.9",
"html-react-parser": "^5.1.16",
"next": "^14.2.11",
"plaiceholder": "^3.0.0",
"postcss": "^8.4.45",
"qs": "^6.13.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-focus-lock": "^2.13.2",
"react-instantsearch": "^7.13.0",
"react-instantsearch-nextjs": "^0.3.10",
"react-instantsearch": "^7.13.1",
"react-instantsearch-nextjs": "^0.3.11",
"react-slick": "^0.30.2",
"react-super-responsive-table": "^6.0.0",
"react-tiny-oembed": "^1.1.0",
"sharp": "^0.33.5",
"tailwind-merge": "^2.5.2",
"tailwindcss": "^3.4.10",
"tailwindcss": "^3.4.11",
"typescript": "^5.6.2",
"usehooks-ts": "^3.1.0"
},
Expand All @@ -55,20 +55,20 @@
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.2.3",
"@next/bundle-analyzer": "^14.2.9",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-links": "^8.2.9",
"@next/bundle-analyzer": "^14.2.11",
"@storybook/addon-essentials": "^8.3.0",
"@storybook/addon-interactions": "^8.3.0",
"@storybook/addon-links": "^8.3.0",
"@storybook/addon-styling": "^1.3.7",
"@storybook/blocks": "^8.2.9",
"@storybook/nextjs": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/blocks": "^8.3.0",
"@storybook/nextjs": "^8.3.0",
"@storybook/react": "^8.3.0",
"@storybook/testing-library": "^0.2.2",
"@types/react-slick": "^0.23.13",
"concurrently": "^9.0.0",
"concurrently": "^9.0.1",
"encoding": "^0.1.13",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.9",
"eslint-config-next": "^14.2.11",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -77,7 +77,7 @@
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"react-docgen": "^7.0.3",
"storybook": "^8.2.9",
"storybook": "^8.3.0",
"storybook-addon-module-mock": "^1.3.4",
"tsconfig-paths-webpack-plugin": "^4.1.0"
},
Expand Down
9 changes: 8 additions & 1 deletion src/lib/gql/gql-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export const buildHeaders = (headers?: HeadersInit, isPreviewMode?: boolean): He
isPreviewMode ? process.env.DRUPAL_BASIC_AUTH_ADMIN || process.env.DRUPAL_BASIC_AUTH : process.env.DRUPAL_BASIC_AUTH
) as string

requestHeaders.set("Authorization", "Basic " + Buffer.from(authCreds).toString("base64"))
if (process.env.DRUPAL_REQUEST_HEADERS) {
const envRequestHeaders: Record<string, string> = JSON.parse(process.env.DRUPAL_REQUEST_HEADERS)
Object.keys(envRequestHeaders).map(key => {
requestHeaders.set(key, envRequestHeaders[key])
})
}

if (authCreds) requestHeaders.set("Authorization", "Basic " + Buffer.from(authCreds).toString("base64"))
return requestHeaders
}
Loading

0 comments on commit 90638c6

Please sign in to comment.