check token on api post request
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { html } from "@/store";
|
||||
import config from "@/config";
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method === "POST") {
|
||||
if (req.headers.token !== config.token) {
|
||||
res.status(403).json({ error: "wrong token" });
|
||||
return;
|
||||
}
|
||||
html.set(req.body.html);
|
||||
}
|
||||
res.status(200).json({
|
||||
|
||||
Reference in New Issue
Block a user