mirror of
https://github.com/sr229/kuru-kuru.git
synced 2024-09-20 04:10:33 +00:00
feat: Add user agent check
Add code to check if useragent is a browser
This commit is contained in:
parent
cdf547e4bd
commit
725c7a1d24
1 changed files with 11 additions and 0 deletions
|
@ -74,6 +74,17 @@ export const handler: Handlers = {
|
|||
},
|
||||
POST: async (req, ctx) => {
|
||||
const body = await req.json();
|
||||
const headers = req.headers;
|
||||
|
||||
// check if useragent is a browser
|
||||
// we can use the Sec-Ch-Ua header but it's not supported by all browsers
|
||||
if (!headers.get("sec-ch-ua")) {
|
||||
return new Response("", {
|
||||
status: 403,
|
||||
statusText: "Forbidden",
|
||||
});
|
||||
}
|
||||
|
||||
await setGlobalStatistics(body.data);
|
||||
|
||||
const updatedCount = await getGlobalStatistics();
|
||||
|
|
Loading…
Reference in a new issue