Site name: https://resolv.netlify.app
Issue: My code works just fine on the dev environment, but when I deploy it to the live server I am met with this 502 error saying the site cannot load my functions:
Things I’ve Already Tried/Discovered:
- Error happens in less than 10 sec (time is not the issue)
- Made sure npm and node versions are the same on local and prod
- Used ${process.env.URL} to create a definite path… didn’t work
- Functions are successfully getting deployed (seen in my logs)
Here’s my code. I’ve added everything in case there’s a function that I am using that isn’t supported by Netlify’s current version of node (as I saw in another solution):
const validateEmail = (email) => {
return email.indexOf('@') !== -1;
};
async function registerUser() {
const form = document.getElementById('input');
const successBox = document.getElementById('success-box');
const errorBox = document.getElementById('error-box');
const feedbackBox = document.getElementById('feedback-box');
const email = document.getElementById('email-input').value;
if (!validateEmail(email)) {
feedbackBox.classList.add('d-block');
return;
}
const headers = new Headers();
headers.append('Content-Type', 'application/json');
const options = {
method: 'POST',
headers,
body: JSON.stringify({email}),
};
const response = await fetch('/.netlify/functions/index', options);
if (response.ok) {
form.classList.add('d-none');
successBox.classList.remove('d-none');
feedbackBox.classList.add('d-none');
}
else {
form.classList.add('d-none');
errorBox.classList.remove('d-none');
}
}
I pray you guys can help… been at this one for 6 hours