@@ -5,10 +5,12 @@ import { NextResponse, type NextRequest } from "next/server";
55import calcomSignupHandler from "@calcom/feature-auth/signup/handlers/calcomHandler" ;
66import selfHostedSignupHandler from "@calcom/feature-auth/signup/handlers/selfHostedHandler" ;
77import { FeaturesRepository } from "@calcom/features/flags/features.repository" ;
8+ import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError" ;
89import { IS_PREMIUM_USERNAME_ENABLED } from "@calcom/lib/constants" ;
910import getIP from "@calcom/lib/getIP" ;
1011import { HttpError } from "@calcom/lib/http-error" ;
1112import logger from "@calcom/lib/logger" ;
13+ import { piiHasher } from "@calcom/lib/server/PiiHasher" ;
1214import { checkCfTurnstileToken } from "@calcom/lib/server/checkCfTurnstileToken" ;
1315import { prisma } from "@calcom/prisma" ;
1416import { signupSchema } from "@calcom/prisma/zod-utils" ;
@@ -38,6 +40,12 @@ async function handler(req: NextRequest) {
3840 const remoteIp = getIP ( req ) ;
3941 // Use a try catch instead of returning res every time
4042 try {
43+ // Rate limit: 10 signups per 60 seconds per IP
44+ await checkRateLimitAndThrowError ( {
45+ rateLimitingType : "core" ,
46+ identifier : `api:signup:${ piiHasher . hash ( remoteIp ) } ` ,
47+ } ) ;
48+
4149 const body = await parseRequestData ( req ) ;
4250 await checkCfTurnstileToken ( {
4351 token : req . headers . get ( "cf-access-token" ) as string ,
0 commit comments