It's impossible to subscribe blog updates.

I suspect process.env.MAILCHIMP_URL is undefined, because according to api error, axios tries to hit 127.0.0.1:80 - this is default axios behavior when url is not defined.
Another thing - add .catch() block to give more user friendly error message, because API response shouldn't look like this (look at screenshot).
website/src/api/submit.js
const axios = require(`axios`);
const validateEmail = (email) =>
String(email)
.toLowerCase()
.match(
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
export default function handler(req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
if (!req?.body?.email || !validateEmail(req?.body?.email)) {
res.status(400).json({ error: true });
return;
}
axios
.post(
process.env.MAILCHIMP_URL, // <--- I think MAILCHIMP_URL is undefined
{
email_address: req.body.email,
status: 'subscribed',
},
{
auth: {
username: 'novu',
password: process.env.MAILCHIMP_URL_KEY,
},
}
)
.then(() => {
res.status(200).json({ sent: true });
});
}
It's impossible to subscribe blog updates.
I suspect
process.env.MAILCHIMP_URLis undefined, because according to api error, axios tries to hit127.0.0.1:80- this is default axios behavior when url is not defined.Another thing - add
.catch()block to give more user friendly error message, because API response shouldn't look like this (look at screenshot).