Based on your situation where the code works locally but fails in your self-hosted Convex deployment (Docker), this is likely an environment-specific issue. Here are the key things to check:
1. Environment Variables
Ensure that AUTH_RESEND_KEY is properly set in your Docker deployment environment. The error might be occurring because the API key isn't available in the Docker container.
For self-hosted deployments, you need to make sure environment variables are passed to the Docker container. Check your Docker configuration to ensure the environment variable is being set.
2. External Packages in Docker
Since you've added resend to externalPackages in convex.json, the package needs to be installed on the server. According to the external packages documentation:
Packages marked as external are installed from npm the first time you push code that uses them. The version installed matches the version installed in the node_modules folder on your local machine.
In a self-hosted Docker environment, you may need to ensure:
- The Docker container has network access to npm
- The
node_modules directory is properly synchronized
- The package installation process can complete successfully
3. Node Runtime
Make sure your action file includes the "use node"; directive at the top, as external packages require the Node.js runtime:
"use node";
import { Resend as ResendAPI } from "resend";
4. Docker-Specific Considerations
For self-hosted deployments, check:
- Docker container logs for any package installation errors
- Network connectivity from the container to external services
- File permissions in the Docker container
- Whether the deployment process completed successfully