feat: add ReCaptchaV2 & Turnstile
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
import { captchaPlugins } from '../middleware/captcha';
|
||||
import { createErrorResponse, createSuccessResponse } from '../utils';
|
||||
import hCaptchaPlugin from "@cloudflare/pages-plugin-hcaptcha";
|
||||
|
||||
export const onRequestPost = [
|
||||
async (context) => {
|
||||
return hCaptchaPlugin({
|
||||
secret: context.env.hcaptcha_secret_key,
|
||||
sitekey: context.env.hcaptcha_site_key,
|
||||
onError: (context) => {
|
||||
console.error("hCaptcha error:", context.error);
|
||||
return createErrorResponse("hCaptcha verification failed", 403);
|
||||
}
|
||||
})(context);
|
||||
},
|
||||
...captchaPlugins,
|
||||
async (context) => {
|
||||
try {
|
||||
const { request, env } = context;
|
||||
|
||||
Reference in New Issue
Block a user