Lucia branch: Check `sendResult` and forward `PUBLIC_SUPPORT_EMAIL` and `RESEND_API_KEY` vars to CF deployment
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
}
I just saw that there's a TODO in the code to check the sendResult:
https://github.com/timothymiller/t4-app/blob/325b5e58a39bf9cd4019db6273ad6ce62889cf2d/packages/api/src/auth/user.ts#L224
In this case, from was missing because it's passed like this
https://github.com/timothymiller/t4-app/blob/325b5e58a39bf9cd4019db6273ad6ce62889cf2d/packages/api/src/auth/user.ts#L214
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_EMAILandRESEND_API_KEYGH 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
:+1: makes sense. I'm not personally super motivated to implement this... so if someone else wants to submit a PR... 🎉