'When i fetch Heroku deployed a link, there is an error 500 (Internal Server Error)

If i used http://localhost:5000/login everything is working. When i used live link https://auto-shoroom.herokuapp.com/login there's the error POST https://auto-shoroom.herokuapp.com/login 500 (Internal Server Error)

The code below with live Heroku link .This code aren't working

if (user) {
        fetch('https://auto-shoroom.herokuapp.com/login', {
            method: 'POST',
            body: JSON.stringify({
                email: user.email 
            }),
            headers: {
                'Content-type': 'application/json',
            },
        })
            .then(res => res.json())
            .then(data => {
                localStorage.setItem("accessToken", data.token)
                navigate(from, { replace: true });
            });
    }

The code below with localhost link .This code is working

if (user) {
        fetch('http://localhost:5000/login', {
            method: 'POST',
            body: JSON.stringify({
                email: user.email 
            }),
            headers: {
                'Content-type': 'application/json',
            },
        })
            .then(res => res.json())
            .then(data => {
                localStorage.setItem("accessToken", data?.token)
                navigate(from, { replace: true });
            });
    }


Solution 1:[1]

Check Reveal Config Vars in your heroku project setting. And you need to add KEY and VALUE in Reveal Config Vars. And that's key value in your .env file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr.Mads