I'm trying to add a "forgot password" link in my application, using the built-in API provided by Strapi. I've included the configuration for Sendgrid in config/plugins.js:
module.exports = ({ env }) => ({
email: {
provider: "sendgrid",
providerOptions: {
apiKey: env('SENDGRID_API_KEY'),
},
settings: {
defaultFrom: "myemail@gmail.com",
defaultReplyTo: "myemail@gmail.com",
},
},
});
Every answer I find about this error is about adding the API key in the environment variables, which I've already done (and re-done) several times. I also re-created my API key twice, in case it expired, but it's still the same. I don't understand, it was working perfectly well a couple days ago but now I'm stuck on this error. Any idea what could be the issue here?
Probably indeed the expression env('SENDGRID_API_KEY') is not resolving the correct api key. You can also directly put your api key in the json like this:
module.exports = ({ env }) => ({
email: {
provider: "sendgrid",
providerOptions: {
apiKey: 'SG.MY_SENDGRID_API_KEY',// <== not using the env function
},
settings: {
defaultFrom: "myemail@gmail.com",
defaultReplyTo: "myemail@gmail.com",
},
},
});
If this works, the plugin is working, and you can focus on why the env() function is not resolving the variable