File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
packages/gatsby-source-contentful/src Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -29,22 +29,28 @@ exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`).extendNodeTyp
2929const validateContentfulAccess = async pluginOptions => {
3030 if ( process . env . NODE_ENV === `test` ) return undefined
3131
32- await fetch ( `https://${ pluginOptions . host } /spaces/${ pluginOptions . spaceId } ` , {
33- headers : {
34- Authorization : `Bearer ${ pluginOptions . accessToken } ` ,
35- "Content-Type" : `application/json` ,
36- } ,
37- } )
32+ await fetch (
33+ `https://${ pluginOptions . host } /spaces/${ pluginOptions . spaceId } /environments/${ pluginOptions . environment } /content_types` ,
34+ {
35+ headers : {
36+ Authorization : `Bearer ${ pluginOptions . accessToken } ` ,
37+ "Content-Type" : `application/json` ,
38+ } ,
39+ }
40+ )
3841 . then ( res => res . ok )
3942 . then ( ok => {
40- if ( ! ok )
41- throw new Error (
42- `Cannot access Contentful space "${ maskText (
43- pluginOptions . spaceId
44- ) } " with access token "${ maskText (
45- pluginOptions . accessToken
46- ) } ". Make sure to double check them!`
47- )
43+ if ( ! ok ) {
44+ let errorMessage = `Cannot access Contentful space "${ maskText (
45+ pluginOptions . spaceId
46+ ) } " on environment "${
47+ pluginOptions . environment
48+ } with access token "${ maskText (
49+ pluginOptions . accessToken
50+ ) } ". Make sure to double check them!`
51+
52+ throw new Error ( errorMessage )
53+ }
4854 } )
4955
5056 return undefined
You can’t perform that action at this time.
0 commit comments