Added connection logging.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
import { isbot } from 'isbot';
|
import { isbot } from 'isbot';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import {
|
import {
|
||||||
@@ -85,6 +86,16 @@ const schema = {
|
|||||||
export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
||||||
await useCors(req, res);
|
await useCors(req, res);
|
||||||
|
|
||||||
|
req.socket.on('close', () => {
|
||||||
|
console.log('Client closed connection');
|
||||||
|
});
|
||||||
|
|
||||||
|
const abortController = new AbortController();
|
||||||
|
req.on('close', () => {
|
||||||
|
console.log('Request closed');
|
||||||
|
abortController.abort();
|
||||||
|
});
|
||||||
|
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
if (!process.env.DISABLE_BOT_CHECK && isbot(req.headers['user-agent'])) {
|
if (!process.env.DISABLE_BOT_CHECK && isbot(req.headers['user-agent'])) {
|
||||||
return ok(res, { beep: 'boop' });
|
return ok(res, { beep: 'boop' });
|
||||||
|
|||||||
Reference in New Issue
Block a user