@@ -3,8 +3,6 @@ import { SendRawEmailCommand, SESClient } from "@aws-sdk/client-ses"
3
3
4
4
const ENTERPRISE_EMAIL = "[email protected] "
5
5
const SES_FROM_EMAIL = "[email protected] "
6
- const RATE_LIMIT_WINDOW_MS = 60 * 1000 // 1 minute
7
- const MAX_REQUESTS_PER_WINDOW = 3
8
6
9
7
// Configure SES client
10
8
const sesClient = new SESClient ( {
@@ -15,34 +13,6 @@ const sesClient = new SESClient({
15
13
} ,
16
14
} )
17
15
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
-
46
16
function sanitizeInput ( input : string ) : string {
47
17
return input
48
18
. replace ( / < s c r i p t \b [ ^ < ] * (?: (? ! < \/ s c r i p t > ) < [ ^ < ] * ) * < \/ s c r i p t > / gi, "" )
@@ -120,16 +90,6 @@ Reply to this email to respond directly to the sender.
120
90
121
91
export async function POST ( request : NextRequest ) {
122
92
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
-
133
93
const body = await request . json ( )
134
94
const { email, message } = body
135
95
0 commit comments