netlify - 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 以修复它。
有谁知道该怎么做?
解决方案
我已经设法解决了。
由于 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,
},
});
},
},
};
推荐阅读
- php - 跨api调用laravel的环境文件问题
- ansible - 在所有元素中创建具有相同值的字典
- cordova - 带有 Cast Chrome Sender Framework API 的 Cordova 插件
- jwt - 如何从 Azure Active Directory 获取公共证书
- java - 在java 8中从文件行中拆分字符的有效方法
- php - 数据表在 Codeigniter 上的加载速度非常慢
- php - Laravel 在销毁路线上缺少必需的参数
- linux - 有没有办法让主线程完成自己的任务而不等待它的子线程?
- nginx - nginx rewrite中括号的含义
- material-ui - 如何垂直对齐材质ui复选框