test(staging): allow setting API host via env variable
This commit is contained in:
committed by
Benedikt Rötsch
parent
2706e31411
commit
1621369d24
@@ -101,7 +101,10 @@ module.exports.postSettings = async (request, response, next) => {
|
|||||||
try {
|
try {
|
||||||
await createClient({
|
await createClient({
|
||||||
space: spaceId,
|
space: spaceId,
|
||||||
accessToken: deliveryToken
|
accessToken: deliveryToken,
|
||||||
|
// Environment variable is used here to enable testing this app internally at Contentful.
|
||||||
|
// You can just omit the host since it defaults to 'cdn.contentful.com'
|
||||||
|
host: process.env.CONTENTFUL_DELIVERY_API_HOST
|
||||||
}).getSpace()
|
}).getSpace()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response.status === 401) {
|
if (err.response.status === 401) {
|
||||||
@@ -129,7 +132,9 @@ module.exports.postSettings = async (request, response, next) => {
|
|||||||
await createClient({
|
await createClient({
|
||||||
space: spaceId,
|
space: spaceId,
|
||||||
accessToken: previewToken,
|
accessToken: previewToken,
|
||||||
host: 'preview.contentful.com'
|
// Environment variable is used here to enable testing this app internally at Contentful.
|
||||||
|
// You should use 'preview.contentful.com' as host to use the preview api
|
||||||
|
host: process.env.CONTENTFUL_PREVIEW_API_HOST
|
||||||
}).getSpace()
|
}).getSpace()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response.status === 401) {
|
if (err.response.status === 401) {
|
||||||
|
|||||||
@@ -18,20 +18,25 @@ module.exports.initClients = (options) => {
|
|||||||
const applicationName = `the-example-app.nodejs/${version}`
|
const applicationName = `the-example-app.nodejs/${version}`
|
||||||
|
|
||||||
const config = options || {
|
const config = options || {
|
||||||
spaceId: process.env.CF_SPACE_ID,
|
spaceId: process.env.CONTENTFUL_SPACE_ID,
|
||||||
deliveryToken: process.env.CF_DELIVERY_TOKEN,
|
deliveryToken: process.env.CONTENTFUL_DELIVERY_TOKEN,
|
||||||
previewToken: process.env.CF_PREVIEW_TOKEN
|
previewToken: process.env.CONTENTFUL_PREVIEW_TOKEN
|
||||||
}
|
}
|
||||||
deliveryClient = createClient({
|
deliveryClient = createClient({
|
||||||
application: applicationName,
|
application: applicationName,
|
||||||
space: config.spaceId,
|
space: config.spaceId,
|
||||||
accessToken: config.deliveryToken
|
accessToken: config.deliveryToken,
|
||||||
|
// Environment variable is used here to enable testing this app internally at Contentful.
|
||||||
|
// You can just omit the host since it defaults to 'cdn.contentful.com'
|
||||||
|
host: process.env.CONTENTFUL_DELIVERY_API_HOST
|
||||||
})
|
})
|
||||||
previewClient = createClient({
|
previewClient = createClient({
|
||||||
application: applicationName,
|
application: applicationName,
|
||||||
space: config.spaceId,
|
space: config.spaceId,
|
||||||
accessToken: config.previewToken,
|
accessToken: config.previewToken,
|
||||||
host: 'preview.contentful.com'
|
// Environment variable is used here to enable testing this app internally at Contentful.
|
||||||
|
// You should use 'preview.contentful.com' as host to use the preview api
|
||||||
|
host: process.env.CONTENTFUL_PREVIEW_API_HOST
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ NODE_ENV=development
|
|||||||
CONTENTFUL_SPACE_ID=qz0n5cdakyl9
|
CONTENTFUL_SPACE_ID=qz0n5cdakyl9
|
||||||
CONTENTFUL_DELIVERY_TOKEN=580d5944194846b690dd89b630a1cb98a0eef6a19b860ef71efc37ee8076ddb8
|
CONTENTFUL_DELIVERY_TOKEN=580d5944194846b690dd89b630a1cb98a0eef6a19b860ef71efc37ee8076ddb8
|
||||||
CONTENTFUL_PREVIEW_TOKEN=e8fc39d9661c7468d0285a7ff949f7a23539dd2e686fcb7bd84dc01b392d698b
|
CONTENTFUL_PREVIEW_TOKEN=e8fc39d9661c7468d0285a7ff949f7a23539dd2e686fcb7bd84dc01b392d698b
|
||||||
|
CONTENTFUL_DELIVERY_API_HOST=cdn.contentful.com
|
||||||
|
CONTENTFUL_PREVIEW_API_HOST=preview.contentful.com
|
||||||
CONTENTFUL_QA_SPACE_ID=jnzexv31feqf
|
CONTENTFUL_QA_SPACE_ID=jnzexv31feqf
|
||||||
CONTENTFUL_QA_DELIVERY_TOKEN=7c1c321a528a25c351c1ac5f53e6ddc6bcce0712ecebec60817f53b35dd3c42b
|
CONTENTFUL_QA_DELIVERY_TOKEN=7c1c321a528a25c351c1ac5f53e6ddc6bcce0712ecebec60817f53b35dd3c42b
|
||||||
CONTENTFUL_QA_PREVIEW_TOKEN=4310226db935f0e9b6b34fb9ce6611e2061abe1aab5297fa25bd52af5caa531a
|
CONTENTFUL_QA_PREVIEW_TOKEN=4310226db935f0e9b6b34fb9ce6611e2061abe1aab5297fa25bd52af5caa531a
|
||||||
|
|||||||
@@ -2,4 +2,6 @@ NODE_ENV=development
|
|||||||
CONTENTFUL_SPACE_ID=qz0n5cdakyl9
|
CONTENTFUL_SPACE_ID=qz0n5cdakyl9
|
||||||
CONTENTFUL_DELIVERY_TOKEN=580d5944194846b690dd89b630a1cb98a0eef6a19b860ef71efc37ee8076ddb8
|
CONTENTFUL_DELIVERY_TOKEN=580d5944194846b690dd89b630a1cb98a0eef6a19b860ef71efc37ee8076ddb8
|
||||||
CONTENTFUL_PREVIEW_TOKEN=e8fc39d9661c7468d0285a7ff949f7a23539dd2e686fcb7bd84dc01b392d698b
|
CONTENTFUL_PREVIEW_TOKEN=e8fc39d9661c7468d0285a7ff949f7a23539dd2e686fcb7bd84dc01b392d698b
|
||||||
|
CONTENTFUL_DELIVERY_API_HOST=cdn.contentful.com
|
||||||
|
CONTENTFUL_PREVIEW_API_HOST=preview.contentful.com
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|||||||
Reference in New Issue
Block a user