Skip to content

Commit

Permalink
new env
Browse files Browse the repository at this point in the history
  • Loading branch information
popovevgen committed Mar 11, 2024
1 parent 1b2902c commit 9f0fc4b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1,866 deletions.
13 changes: 9 additions & 4 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
CONTENTFUL_SPACE_ID=
CONTENTFUL_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_SECRET=
CONTENTFUL_SPACE_ID=nq2l1w8kzz2j
CONTENTFUL_ACCESS_TOKEN=3XF8HkhjIhabRmN_jMpeiB1BqgXIrcLbRWldDwZq6LY
CONTENTFUL_PREVIEW_ACCESS_TOKEN=HNxd4rW3mhPRWo_p-U-3hmqNjQZx4IbkYKopiC0ClQI
CONTENTFUL_PREVIEW_SECRET=HNxd4rW3mhPRWo_p-U-3hmqNjQZx4IbkYKopiC0ClQI
CONTENTFUL_WEBHOOK_SECRET=123456
CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-Fes2e4Vsr0pCyC-bsmodkTGkZzUm1_gKpXAz2rkQqbA


CONTENTFUL_ACCESS_STAGING_TOKEN=sqHu8jiZu1Y8Mc0vSZJW-GeF7N8pkyg-SH0yiJ0QkMI
2 changes: 1 addition & 1 deletion contentful/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const spaceImport = require('contentful-import')
const exportFile = require('./export.json')

const [CONTENTFUL_SPACE_ID, CONTENTFUL_MANAGEMENT_TOKEN] = process.argv.slice(2)
const { CONTENTFUL_SPACE_ID, CONTENTFUL_MANAGEMENT_TOKEN } = process.env;

if (!CONTENTFUL_SPACE_ID || !CONTENTFUL_MANAGEMENT_TOKEN) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ content {

async function fetchGraphQL(query, preview = false) {
return fetch(
`https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}`,
`https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}/environments/qa`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${
preview
? process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN
: process.env.CONTENTFUL_ACCESS_TOKEN
: process.env.CONTENTFUL_ACCESS_STAGING_TOKEN
}`,
},
body: JSON.stringify({ query }),
Expand Down
2 changes: 1 addition & 1 deletion lib/contentfull.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {createClient} from 'contentful'

const clientContentful = createClient({
space: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN
accessToken: process.env.CONTENTFUL_ACCESS_STAGING_TOKEN
});

export default clientContentful
Loading

0 comments on commit 9f0fc4b

Please sign in to comment.