Open srestraj opened 6 months ago
I am getting the same issue
same
So I came across one Vercel article, which suggests that on the free plan, we don't have the option to create custom IP for our domains as Vercel deployments use a range of IP addresses that can't be easily specified for Mialgun's IP Allowlist. So, we have two options:
I resolved the 401 Unauthorized error by adding 0.0.0.0/0
to my IP Access Management in Mailgun. This might not be the ideal solution, but it worked for me. If you're facing the same issue, you can try this approach.
Running into the same issue testing locally. When running the curl
example the email goes through. When trying the node example getting the same 401
error.
I have a Next.js 14 project deployed on Vercel, where I've integrated the Mailgun API to send emails using this package. The integration works fine locally. However, after deploying to production on Vercel, I'm consistently encountering an "Unauthorized" error when attempting to send emails via the Mailgun API.
I've already added Vercel's IP, i.e. 76.76.21.21 to our domain's whitelist on Mailgun, but still no luck.
I've thoroughly checked and verified the API keys, environment variables and permissions and they're all fine. I've also included my code below for reference.
I've also attached a screenshot below for reference.