Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lucia branch: Check sendResult and forward PUBLIC_SUPPORT_EMAIL and RESEND_API_KEY vars to CF deployment #130

Open
Boscop opened this issue Dec 28, 2023 · 1 comment

Comments

@Boscop
Copy link

Boscop commented Dec 28, 2023

When the user wants to reset their password, the call to the backend returns 200 so the frontend thinks the email was sent,
but the email doesn't get sent: In the resend.com logs, it shows HTTP error 422 because the from field is missing in the payload:

{
    "name": "missing_required_field",
    "message": "Missing `from` field.",
    "statusCode": 422
}
image

I just saw that there's a TODO in the code to check the sendResult:

// TODO check sendResult response for success

In this case, from was missing because it's passed like this

from: ctx.env.PUBLIC_SUPPORT_EMAIL,

and PUBLIC_SUPPORT_EMAIL was undefined.

So we could use this issue to cover both:

  • checking sendResult: In case of HTTP error, forward that so that the frontend doesn't think the email got sent when it didn't
  • Adding the PUBLIC_SUPPORT_EMAIL and RESEND_API_KEY GH action secrets (.github/workflows/backend.yml) to be forwarded to the CF deployment, like:
      - name: Deploy
        uses: cloudflare/[email protected]
        with:
          wranglerVersion: '3.15.0'
          apiToken: ${{ secrets.CF_API_TOKEN }}
          workingDirectory: packages/api
          command: deploy src/worker.ts
          packageManager: bun
          secrets: |
            APP_URL
            CI
            RESEND_API_KEY
            PUBLIC_SUPPORT_EMAIL
        env:
          APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
          CI: true
          RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
          PUBLIC_SUPPORT_EMAIL: ${{ secrets.PUBLIC_SUPPORT_EMAIL }}
          NO_D1_WARNING: true

@rmarscher

@rmarscher
Copy link
Contributor

👍 makes sense. I'm not personally super motivated to implement this... so if someone else wants to submit a PR... 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants