首页 > 解决方案 > Strapi 和 Netlify 构建错误 - 有效负载超过 140kb 的限制

问题描述

我一直在使用 Strapi 和 Netlify 构建 gatsby 页面已经有一段时间了,今天我尝试在一个较大的登录页面上进行一些更改,但是在构建触发器之后我在 Netlify 控制台中遇到了这个错误。

strapi error enqueueing build. build payload exceeded limit of 140 kb. please make sure environment variables and/or webhook body don't exceed this size.

老实说,我什至不知道在哪里看它 Strapi 以修复它。

有谁知道该怎么做?

标签: netlifystrapi

解决方案


我已经设法解决了。

由于 Gatsby 甚至不需要 Strapi 的 webhook 中的任何此类有效负载,因此对其进行排序的方式只是忽略他们提供的开箱即用的解决方案,该解决方案将所有数据发送到 hook 内。

您可以做的是转到您的 API 模型 (./api/posts/models./posts.js) 并简单地向特定的 webhook URL 发出 post 请求,而无需实际有效负载:

"use strict";
const axios = require("axios");

module.exports = {
  lifecycles: {
    async afterCreate() {
      axios({
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        url: "YOURHOOKURL",
        body: {
          force_build: true,
        },
      });
    },
    async afterUpdate() {
      axios({
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
       url: "YOURHOOKURL",
        body: {
          force_build: true,
        },
      });
    },
    async afterDelete() {
      axios({
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
      url: "YOURHOOKURL",
        body: {
          force_build: true,
        },
      });
    },
  },
};


推荐阅读