fix: fix rate limit for newsletter subscription when sign up
This commit is contained in:
parent
335c3b46d6
commit
f6a2df402e
@ -163,7 +163,12 @@ export function getLocaleFromRequest(request?: Request): Locale {
|
||||
*/
|
||||
async function onCreateUser(user: User) {
|
||||
// Auto subscribe user to newsletter after sign up if enabled in website config
|
||||
// Add a delay to avoid hitting Resend's 1 email per second limit
|
||||
if (user.email && websiteConfig.newsletter.autoSubscribeAfterSignUp) {
|
||||
// Delay newsletter subscription by 2 seconds to avoid rate limiting
|
||||
// This ensures the email verification email is sent first
|
||||
// Using 2 seconds instead of 1 to provide extra buffer for network delays
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const subscribed = await subscribe(user.email);
|
||||
if (!subscribed) {
|
||||
@ -174,6 +179,7 @@ async function onCreateUser(user: User) {
|
||||
} catch (error) {
|
||||
console.error('Newsletter subscription error:', error);
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Add register gift credits to the user if enabled in website config
|
||||
|
Loading…
Reference in New Issue
Block a user