title: Netlify deploy can't connect to Heroku backend
body: <p>I've built a wee program that works fine when I run it locally. I've deployed the backend to Heroku, and I can access that either by going straight to the URL (<a href="http://gymbud-tracker.herokuapp.com/users" rel="nofollow noreferrer">http://gymbud-tracker.herokuapp.com/users</a>) or when running the frontend locally. So far so good.</p>
  <p>However, when I run npm run-script build and deploy it to Netlify, something goes wrong, and any attempt to access the server gives me the following error in the console:</p>
  <pre><code>    auth.js:37 Error: Network Error
      at e.exports (createError.js:16)
      at XMLHttpRequest.p.onerror (xhr.js:99)
  </code></pre>
  <p>The action that is pushing that error is the following, if it is relevant:</p>
  <pre><code>export const signin = (formData, history) =&gt; async (dispatch) =&gt; {
    try {
      const { data } = await api.signIn(formData);
  
      dispatch({ type: AUTH, data });
  
      history.push(&quot;../signedin&quot;);
    } catch (error) {
      console.log(error);
    }
  };
  </code></pre>
  <p>I've been tearing my hair out trying to work out what is changing when I build and deploy, but cannot work it out.</p>
  <p>As I say, if I run the front end locally then it access the Heroku backend no problem - no errors, and working exactly as I'd expect. The API call is correct, I believe: const API = axios.create({baseURL: 'http://gymbud-tracker.herokuapp.com/' });</p>
  <p>I wondered if it was an issue with network access to the MongoDB database that Heroku is linked to, but it's open to &quot;0.0.0.0/0&quot; (I've not taken any security precautions yet, don't kill me!). The MDB database is actually in the same collection as other projects I've used, that haven't had this problem at all.</p>
  <p>Any ideas what I need to do?</p>
  <p>The front end is live here: <a href="https://gym-bud.netlify.app/" rel="nofollow noreferrer">https://gym-bud.netlify.app/</a>
  And the whole thing is deployed to GitHub here: <a href="https://github.com/gordonmaloney/gymbud" rel="nofollow noreferrer">https://github.com/gordonmaloney/gymbud</a></p>