chore: raise size limit for text/plain requests

This commit is contained in:
Sainan 2025-01-19 12:10:24 +01:00
parent 1c186450e1
commit 3c99b748dc
2 changed files with 12 additions and 19 deletions

View File

@ -17,7 +17,7 @@ const app = express();
app.use(bodyParser.raw()); app.use(bodyParser.raw());
app.use(express.json()); app.use(express.json());
app.use(bodyParser.text()); app.use(bodyParser.text({ limit: "4mb" }));
app.use(requestLogger); app.use(requestLogger);
app.use("/api", apiRouter); app.use("/api", apiRouter);

View File

@ -1091,17 +1091,11 @@ function doAddAllMods() {
modsAll.length != 0 && modsAll.length != 0 &&
window.confirm("Are you sure you want to add " + modsAll.length + " mods to your account?") window.confirm("Are you sure you want to add " + modsAll.length + " mods to your account?")
) { ) {
// Batch to avoid PayloadTooLargeError
const batches = [];
for (let i = 0; i < modsAll.length; i += 1000) {
batches.push(modsAll.slice(i, i + 1000));
}
batches.forEach(batch => {
$.post({ $.post({
url: "/api/missionInventoryUpdate.php?" + window.authz, url: "/api/missionInventoryUpdate.php?" + window.authz,
contentType: "text/plain", contentType: "text/plain",
data: JSON.stringify({ data: JSON.stringify({
RawUpgrades: batch.map(mod => ({ RawUpgrades: modsAll.map(mod => ({
ItemType: mod, ItemType: mod,
ItemCount: 21 // To fully upgrade certain arcanes ItemCount: 21 // To fully upgrade certain arcanes
})) }))
@ -1109,7 +1103,6 @@ function doAddAllMods() {
}).done(function () { }).done(function () {
updateInventory(); updateInventory();
}); });
});
} }
}); });
}); });