test(staging): allow setting API host via env variable

This commit is contained in:
Benedikt Rötsch
2018-01-25 14:57:50 +01:00
committed by Benedikt Rötsch
parent 2706e31411
commit 1621369d24
4 changed files with 21 additions and 7 deletions

View File

@@ -101,7 +101,10 @@ module.exports.postSettings = async (request, response, next) => {
try {
await createClient({
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()
} catch (err) {
if (err.response.status === 401) {
@@ -129,7 +132,9 @@ module.exports.postSettings = async (request, response, next) => {
await createClient({
space: spaceId,
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()
} catch (err) {
if (err.response.status === 401) {