Skip to content

Commit e7a3313

Browse files
committed
revert: custom rate-limit logic
1 parent 8f3f037 commit e7a3313

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

app/api/enterprise-contact/route.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { SendRawEmailCommand, SESClient } from "@aws-sdk/client-ses"
33

44
const ENTERPRISE_EMAIL = "[email protected]"
55
const SES_FROM_EMAIL = "[email protected]"
6-
const RATE_LIMIT_WINDOW_MS = 60 * 1000 // 1 minute
7-
const MAX_REQUESTS_PER_WINDOW = 3
86

97
// Configure SES client
108
const sesClient = new SESClient({
@@ -15,34 +13,6 @@ const sesClient = new SESClient({
1513
},
1614
})
1715

18-
// Log the region being used for debugging
19-
console.log("Using AWS SES region:", process.env.SES_REGION || "us-east-2")
20-
21-
// Simple in-memory rate limiting (in production, use Redis or similar)
22-
const requestHistory = new Map<string, number[]>()
23-
24-
function isRateLimited(identifier: string): boolean {
25-
const now = Date.now()
26-
const requests = requestHistory.get(identifier) || []
27-
28-
// Filter out requests outside the current window
29-
const recentRequests = requests.filter(
30-
(timestamp) => now - timestamp < RATE_LIMIT_WINDOW_MS
31-
)
32-
33-
// Update the history
34-
requestHistory.set(identifier, recentRequests)
35-
36-
// Check if we're over the limit
37-
if (recentRequests.length >= MAX_REQUESTS_PER_WINDOW) return true
38-
39-
// Add this request
40-
recentRequests.push(now)
41-
requestHistory.set(identifier, recentRequests)
42-
43-
return false
44-
}
45-
4616
function sanitizeInput(input: string): string {
4717
return input
4818
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "")
@@ -120,16 +90,6 @@ Reply to this email to respond directly to the sender.
12090

12191
export async function POST(request: NextRequest) {
12292
try {
123-
// Rate limiting based on a simple identifier (could be improved with real session tracking)
124-
const userAgent = request.headers.get("user-agent") || "unknown"
125-
126-
if (isRateLimited(userAgent)) {
127-
return NextResponse.json(
128-
{ error: "Too many requests. Please try again later." },
129-
{ status: 429 }
130-
)
131-
}
132-
13393
const body = await request.json()
13494
const { email, message } = body
13595

0 commit comments

Comments
 (0)