Сборка Gatsby отлично работает локально и в Netlify, но 401 на страницах Cloudflare

#gatsby #cloudflare #storyblok #cloudflare-pages

#gatsby #cloudflare #storyblok #cloudflare-страницы

Вопрос:

Я интегрировал Storyblok CMS с Gatsby после сбоя развертывания страниц Cloudflare со следующей ошибкой

 09:13:03.832    e[2Ke[1Ae[2Ke[G
09:13:03.832     ERROR #11321  PLUGIN
09:13:03.832    
09:13:03.832    "gatsby-source-storyblok" threw an error while running the sourceNodes
09:13:03.832    lifecycle:
09:13:03.832    
09:13:03.832    Request failed with status code 401
09:13:03.832    
09:13:03.834    
09:13:03.863    e[2Ke[1Ae[2Ke[G
09:13:03.863    e[0m
09:13:03.863    e[0m  e[0me[97me[41mErrore[0me[37me[41m:e[0me[37me[41m e[0me[97me[41mRequest failed with status code 401e[0m
09:13:03.863    e[0m  e[0m
09:13:03.863    e[0m  e[0me[90m-e[0m e[0me[93mcreateError.jse[0me[90m:e[0me[93m16e[0me[37m e[0me[37mcreateErrore[0m
09:13:03.863    e[0m  e[0m  e[0me[90m[repo]/[axios]/lib/core/createError.js:16:15e[0m
09:13:03.863    e[0m  e[0m
09:13:03.863    e[0m  e[0me[90m-e[0m e[0me[93msettle.jse[0me[90m:e[0me[93m17e[0me[37m e[0me[37msettlee[0m
09:13:03.863    e[0m  e[0m  e[0me[90m[repo]/[axios]/lib/core/settle.js:17:12e[0m
09:13:03.863    e[0m  e[0m
09:13:03.863    e[0m  e[0me[90m-e[0m e[0me[93mhttp.jse[0me[90m:e[0me[93m260e[0me[37m e[0me[37mIncomingMessage.handleStreamEnde[0m
09:13:03.863    e[0m  e[0m  e[0me[90m[repo]/[axios]/lib/adapters/http.js:260:11e[0m
09:13:03.864    e[0m  e[0m
09:13:03.864    e[0m  e[0me[90m-e[0m e[0me[93mreadable.jse[0me[90m:e[0me[93m1317e[0me[37m e[0me[37mendReadableNTe[0m
09:13:03.864    e[0m  e[0m  e[0me[90minternal/streams/readable.js:1317:12e[0m
09:13:03.864    e[0m  e[0m
09:13:03.864    e[0m  e[0me[90m-e[0m e[0me[93mtask_queues.jse[0me[90m:e[0me[93m82e[0me[37m e[0me[37mprocessTicksAndRejectionse[0m
09:13:03.864    e[0m  e[0m  e[0me[90minternal/process/task_queues.js:82:21e[0m
09:13:03.864    e[0m  e[0m
09:13:03.864    e[0m
09:13:03.866    
09:13:03.871    e[2Ke[1Ae[2Ke[Gnot finished source and transform nodes - 0.709s
09:13:03.871    
09:13:05.651    Failed: build command exited with code: 1
 

но сборка отлично работает как локально, так и в Netlify. Я также добавил необходимые переменные среды на страницы Cloudflare.

(Я знаю, что означает 401, но, похоже, это происходит только на страницах CF)

package.json

 {

  ...

  "scripts": {
    "develop": "gatsby develop",
    "develop-css": "TAILWIND_MODE=watch postcss -i node_modules/tailwindcss/dis/tailwind.css -o dist/build.css --watch",
    "clean-develop": "gatsby clean amp;amp; gatsby develop",
    "build": "gatsby build",
    "build-css": "postcss -i node_modules/tailwindcss/dis/tailwind.css -o --minify dist/build.css",
    "clean-build": "gatsby clean amp;amp; gatsby build amp;amp; gatsby serve",
    "build-serve": "gatsby build amp;amp; gatsby serve",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook",
    "prepare": "husky install",
    "flow": "flow status amp;amp; echo 'Type checking done!'",
    "format": "pretty-quick amp;amp; echo 'Formatting done!'",
    "lint": "eslint --fix --ext .js,.jsx . amp;amp; ls-lint amp;amp; echo 'Linting done!'",
    "validate": "yarn flow amp;amp; yarn format amp;amp; yarn lint"
  },
  "dependencies": {
    "@fontsource/lexend-deca": "^4.5.1",
    "@fontsource/open-sans": "^4.5.0",
    "@headlessui/react": "^1.4.0",
    "@icons-pack/react-simple-icons": "^4.6.1",
    "@sentry/gatsby": "^6.15.0",
    "@tailwindcss/aspect-ratio": "^0.3.0",
    "@tailwindcss/forms": "^0.3.3",
    "gatsby": "^3.10.2",
    "gatsby-plugin-flow": "^2.10.0",
    "gatsby-plugin-google-gtag": "^3.10.0",
    "gatsby-plugin-image": "^1.10.1",
    "gatsby-plugin-manifest": "^3.10.0",
    "gatsby-plugin-postcss": "^4.12.0",
    "gatsby-plugin-prismic-previews": "^5.2.1",
    "gatsby-plugin-react-helmet": "^4.10.0",
    "gatsby-plugin-robots-txt": "^1.6.8",
    "gatsby-plugin-sharp": "^3.10.2",
    "gatsby-plugin-sitemap": "^4.6.0",
    "gatsby-source-filesystem": "^3.10.0",
    "gatsby-source-prismic": "^5.2.3",
    "gatsby-source-storyblok": "^3.0.2",
    "gatsby-transformer-sharp": "^3.10.0",
    "keen-slider": "^6.0.4",
    "postcss": "^8.3.6",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "storyblok-js-client": "^4.1.5",
    "storyblok-react": "^0.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "@ls-lint/ls-lint": "^1.10.0",
    "@storybook/addon-a11y": "^6.3.7",
    "@storybook/addon-actions": "^6.3.7",
    "@storybook/addon-essentials": "^6.3.7",
    "@storybook/addon-knobs": "^6.3.0",
    "@storybook/addon-links": "^6.3.7",
    "@storybook/addon-postcss": "^2.0.0",
    "@storybook/builder-webpack5": "^6.3.7",
    "@storybook/manager-webpack5": "^6.3.7",
    "@storybook/react": "^6.3.7",
    "autoprefixer": "^10.3.2",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.2.2",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-flowtype": "^5.9.0",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-tailwindcss": "^1.14.3",
    "flow-bin": "^0.156.0",
    "flow-typed": "^3.3.1",
    "gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.24",
    "husky": "^7.0.0",
    "lint-staged": ">=10",
    "postcss-cli": "^8.3.1",
    "prettier": "^2.3.2",
    "pretty-quick": "^3.1.1",
    "prop-types": "^15.7.2",
    "tailwindcss": "^2.2.7",
    "tailwindcss-debug-screens": "^2.1.0"
  },

  ...

}
 

Я NODE_VERSION установил значение 14.17.2 на страницах CF.

Комментарии:

1. Не могли бы вы поделиться своим package.json ?

2. @marcobiedermann какие разделы package.json вам нужны?

3. @marcobiedermann добавлен и обновлен

4. Возможно, вам не хватает некоторых переменных среды для установки учетных данных Storyblok

5. @marcobiedermann Я добавил требуемый env на страницы.