Gatsby Source Drupal 在尝试部署到 netlify/heroku 时未获取数据

发布于 2025-01-11 06:42:02 字数 1629 浏览 0 评论 0 原文

我有一个运行 Gatsby 和 Gatsby-Source-Drupal7 的网站,它是一个使用 Graphql 向 https://stagingsupply.htm-mbs.com/restws_resource.json 并使用 json 数据来查询。我可以通过访问 localhost:8000 在我的计算机上正常运行它,它会创建超过 200k 个节点,但是当我尝试在 Gatsby Cloud 或 Netlify 等任何云服务提供商上部署时,它不会在以下位置获取任何节点或数据:全部来自该网站。

来自控制台的警告 来自

Starting to fetch data from Drupal
warn The gatsby-source-drupal7 plugin has generated no Gatsby nodes. Do you need
 it?

gatsby

gatsby 配置的代码

module.exports = {
    siteMetadata: {
      title: `new`,
        siteUrl: `https://www.yourdomain.tld`,
    },
    plugins: [
      {
        resolve: `gatsby-source-drupal7`,
        options: {
          baseUrl: `https://stagingsupply.htm-mbs.com/`,
          apiBase: `restws_resource.json`, // optional, defaults to `restws_resource.json`
        },
      },
    ]
}

-config.js 来自 node_modules/gatsby-source-drupal7

const createNode = actions.createNode; // Default apiBase to `jsonapi`

    apiBase = apiBase || `restws_resource.json`; // Fetch articles.
    // console.time(`fetch Drupal data`)

    console.log(`Starting to fetch data from Drupal`);
    const data = yield axios.get(`${baseUrl}/${apiBase}`, {
      auth: basicAuth
    });
    const allData = yield Promise.all(_.map(data.data.list,

链接到在本地计算机上运行的存储库 https://github.com/nicholastorr/gatsby-d7

任何和所有帮助将不胜感激

I have a site running Gatsby and Gatsby-Source-Drupal7, it is a plugin that uses Graphql to make an axios get request to https://stagingsupply.htm-mbs.com/restws_resource.json and uses the json data to query. I am able to run it just fine on my computer by going to localhost:8000 and it creates over 200k nodes, but when I try to deploy on any cloud service provider like Gatsby Cloud or Netlify it doesn't fetch any nodes or data at all from the site.

Warning from console

Starting to fetch data from Drupal
warn The gatsby-source-drupal7 plugin has generated no Gatsby nodes. Do you need
 it?

Code

code from gatsby config

module.exports = {
    siteMetadata: {
      title: `new`,
        siteUrl: `https://www.yourdomain.tld`,
    },
    plugins: [
      {
        resolve: `gatsby-source-drupal7`,
        options: {
          baseUrl: `https://stagingsupply.htm-mbs.com/`,
          apiBase: `restws_resource.json`, // optional, defaults to `restws_resource.json`
        },
      },
    ]
}

gatsby-config.js from node_modules/gatsby-source-drupal7

const createNode = actions.createNode; // Default apiBase to `jsonapi`

    apiBase = apiBase || `restws_resource.json`; // Fetch articles.
    // console.time(`fetch Drupal data`)

    console.log(`Starting to fetch data from Drupal`);
    const data = yield axios.get(`${baseUrl}/${apiBase}`, {
      auth: basicAuth
    });
    const allData = yield Promise.all(_.map(data.data.list,

Link to repo that works on local computer https://github.com/nicholastorr/gatsby-d7

any and all help will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木格 2025-01-18 06:42:02

正如您所指出的,您已经使用 NODE_ENVengines 解决方法来使用 Node 版本。我的猜测还依赖于环境之间不匹配的 Node 版本,但如 Netlify docs建议,只有两种方法可以自定义 Node 版本来管理依赖关系。

  • 设置 NODE_VERSION 环境变量。
  • .node-version.nvmrc 文件添加到存储库中站点的基目录中。这也将告诉任何其他使用该
    存储库依赖哪个版本的 Node.js。

如果没有看到 Netlify 构建命令(查看 NODE_VERSION),您的存储库中就没有 .node-version.nvmrc。我会尝试在项目的根目录中创建它,并在其中包含 v14.17.1 并尝试全新安装。

此外,请仔细检查其他与服务器相关的冲突,例如 IP 阻止等。

As you pointed out, you've played around with the Node versions using NODE_ENV and engines workarounds. My guess also relies on a mismatching Node version between environments but as Netlify docs suggests, there are only two ways of customizing Node versions to manage dependencies.

  • Set a NODE_VERSION environment variable.
  • Add a .node-version or .nvmrc file to the site’s base directory in your repository. This will also tell any other developer using the
    repository which version of Node.js it depends on.

Without seeing your Netlify build command (to see the NODE_VERSION) there's no .node-version nor .nvmrc in your repository. I'd try creating it at the root of the project with the v14.17.1 in it and trying a fresh install.

In addition, double-check other server-related conflicts like IP-blocking, etc.

平定天下 2025-01-18 06:42:02

错误与 Gatsby 或 Node 无关,我的网站被阻止了服务器的 IP :>

Error was nothing Gatsby or Node related, my site was block the IP of the server :>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文