Email worker forwarding emails twice?

hey yall. im attempting to set up a catch-all worker to forward "+" emails to their respective custom addresses. for example i have the custom address my@website.com forwarding to myreal@gmail.com. i wrote a worker to catch addresses like my+100orwhatever@website.com and forward said email to myreal@gmail.com. the good news is it works! but maybe a little too much. all the emails are coming in twice at the same time. not sure what im doing wrong or if i have my setup weird. any ideas? note the emails used here are verified and i have both the catchall and my custom emails online.

export default {
  async email(message, env, ctx) {
    // Extract the local part and domain of the email address
    const [localPart, domain] = message.to.split('@');

    // List of existing custom addresses (anonymized)
    const customAddresses = {
      'alias1': 'recipient1@example.com',
      'alias2': 'recipient2@example.com',
      'support': 'support@example.com',
    };

    // Only proceed if the local part contains a '+'
    if (localPart.includes('+')) {
      // Extract the base address (portion before the '+')
      const baseAddress = localPart.split('+')[0];

      // Check if the base address is in the custom addresses list
      const destination = customAddresses[baseAddress];
      if (destination) {
        // Forward to the appropriate destination
        await message.forward(destination);
      } else {
        // Reject if base address is not recognized
        message.setReject(`No such address: ${baseAddress}@${domain}`);
      }
    }
  }
}
Was this page helpful?