前提・実現したいこと
◆使用ツール・言語
Gatsby.js
Contentful
◆前提
当方、プログラミング初心者です。
・gatsby new gatsby-contentful-starter実行済み
・Contentfulにアカウント作成済み
◆実現したいこと
gatsby-contentful-starterでローカルサーバー起動(develop)、ブラウザからのアクセス確認
発生している問題・エラーメッセージ
> node ./bin/setup.js (略) √ Validating content-file √ Initialize client (1s) × Checking if destination space already has any content and retrieving it (20s) → Error: getaddrinfo ENOTFOUND api.contentful.com Apply transformations to source data Push content to destination space The following 1 errors and 5 warnings occurred: 08:54:71 - Connection error occurred. Waiting for 2075 ms before retrying... 08:54:80 - Connection error occurred. Waiting for 2637 ms before retrying... 08:54:44 - Connection error occurred. Waiting for 3449 ms before retrying... 08:54:89 - Connection error occurred. Waiting for 4616 ms before retrying... 08:55:51 - Connection error occurred. Waiting for 6236 ms before retrying... 08:55:76 - Error: Error: getaddrinfo ENOTFOUND api.contentful.com
該当のソースコード
試したこと
◆contentful-cliをインストールし、login -> space useと試したところ、同様のエラーが発生
powershell
1>contentful space use 2 3[warning] Connection error occurred. Waiting for 2002 ms before retrying... 4[warning] Connection error occurred. Waiting for 2637 ms before retrying... 5[warning] Connection error occurred. Waiting for 3329 ms before retrying... 6[warning] Connection error occurred. Waiting for 4573 ms before retrying... 7[warning] Connection error occurred. Waiting for 6286 ms before retrying... 8 Error: getaddrinfo ENOTFOUND api.contentful.com 9 10│ Error: getaddrinfo ENOTFOUND api.contentful.com 11│ 12│ at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
◆contentful config add --proxy example.com:NNNN でプロキシ設定
◆再度、space useを実行し、疎通を確認
powershell
1>contentful space use 2 3? Please select a space: (Use arrow keys) 4>test-space (********vc) 5The example project (********uo)
◆以上の作業でプロキシ設定に不備があると仮定し、gatsby-config.jsにプロキシ設定
※gatsby-source-contentfulにはproxy設定のコマンドがないため
JavaScrip
1require('dotenv').config({ 2 path: `.env.${process.env.NODE_ENV}` 3}) 4 5const contentfulConfig = { 6 spaceId: process.env.CONTENTFUL_SPACE_ID, 7 accessToken: process.env.CONTENTFUL_ACCESS_TOKEN, 8 host: process.env.CONTENTFUL_HOST 9 proxy:{ 10 host: 'sample.proxy', 11 port: ****, 12 } 13} 14 15const { spaceId, accessToken } = contentfulConfig 16 17if (!spaceId || !accessToken) { 18 throw new Error( 19 'Contentful spaceId and the access token need to be provided.' 20 ) 21} 22 23module.exports = { 24 siteMetadata: { 25 title: 'Gatsby Contentful starter', 26 }, 27 pathPrefix: '/gatsby-contentful-starter', 28 plugins: [ 29 'gatsby-transformer-remark', 30 'gatsby-transformer-sharp', 31 'gatsby-plugin-react-helmet', 32 'gatsby-plugin-sharp', 33 { 34 resolve: 'gatsby-source-contentful', 35 options: contentfulConfig, 36 } 37 ], 38}
◆再度、gatsby-contentful-starterにてnpm run setupを試すも同様のエラーが出力
補足情報(FW/ツールのバージョンなど)
◆バージョン情報
Node version: v12.13.0
Gatsby CLI version: 2.8.13
◆参考にしたサイト
ttps://github.com/gatsbyjs/gatsby/issues/4744
ttps://github.com/gatsbyjs/gatsby/pull/17574
以上、よろしくお願いいたします。
あなたの回答
tips
プレビュー