Hello!
I manage a Roblox ranking bot that receives a new ranking request every 1-2 minutes on average. Recently, I have noticed countless failed requests whose error messages indicate a problem with the CSRF token generation.
The Noblox.js package already contains code to handle these errors but it seems a bit hit-and-miss. Once a failed attempt occurs, the issue seems to be persistent for all subsequent requests until about 20-30 minutes later when I assume the token is re-generated correctly. After this time, everything works fine until roughly an hour later when the error returns.
We were using an altered version of Noblox.js until this issue started impacting group operations, so I reinstalled it on the latest version on a fresh server using boilerplate code until, lo and behold, my efforts proved to be fruitless.
Noblox.js Source Code (GitHub)
Using version 4.15.1 (Latest)
The ranking portion of my code:
let init = async () => {
await noblox.setCookie(process.env.COOKIE);
};
init();
app.use((req, res, next) => {
const { key } = req.body;
if (key !== process.env.KEY)
return res.json({
success: false,
message: "Invalid key",
});
next();
});
app.post("/rank", async (req, res) => {
const { userId, newRank, notes } = req.body;
if (newRank > 127)
return res.json({
success: false,
message: "Rank TH",
});
let result = await noblox.setRank(GROUP_ID, userId, newRank).catch((err) => {
console.log("err", err);
return false;
});
if (result === false) return res.json({
success: false,
message: "Error, check logs",
});
return res.json({
success: true,
});
});