silverwolf-x's picture
download
raw
899 Bytes
import type { NextApiRequest, NextApiResponse } from "next";
const regenerate = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.query.secret !== process.env.NEXT_PRIVATE_REGENERATION_SECRET) {
console.error("Error regenerating: Invalid Token.");
return res
.status(401)
.json({ message: "Error regenerating: Invalid token" });
}
if (typeof req.query.path === "string") {
try {
const url = new URL(req.query.path, process.env.NEXT_PUBLIC_APP_URL);
const { pathname: pathToRegenerate } = url;
await res.revalidate(pathToRegenerate);
return res.json({ regenerated: true });
} catch (err) {
console.error("Error regenerating: Cannot parse url.");
return res.status(500).send("Error regenerating: Cannot parse url.");
}
}
return res.status(400).send("No path to regenerate");
};
export default regenerate;

Xet Storage Details

Size:
899 Bytes
·
Xet hash:
9ce9e76b06977a8a72ba148c4bf7ec96f46069044ce5b9001adf18cb2a424739

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.