I have a folder called /api in the root of the application where I access an endpoint from the Frontend /src to send an email. I'd like to call an environment variable here but it is not working with process.env.VUE_APP_APIKEY. What is the right way to do this?
This is the endpoint I am calling the env variable from. This is using express:
let endpoint = function(app) {
app.post('/send-mail', function(req, res) {
sgMail.setApiKey(process.env.VUE_APP_APIKEY);
sgMail
.send(req.body)
.then(() => {
// do something
})
.catch(error => {
// do something
});
return res.send(req.body);
});
};
That sgMail is sendgrid, hence the API key I'm calling is for that service.
VUE_APP_APIKEYdefined as an environment variable?